Skip to content

Commit

Permalink
fix order of arguments in Equal calls, use Len
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Feb 13, 2024
1 parent 1e66bc5 commit 426cf46
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions config/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ func TestAccounts_Remove(t *testing.T) {
accounts := Accounts{acc1, acc2, acc3}

accounts.Remove("account2")
assert.Equal(t, len(accounts), 2)
assert.Len(t, accounts, 2)

_, err := accounts.ByName("account2")
assert.Error(t, err)

accounts.Remove("account4")
assert.Equal(t, len(accounts), 2)
assert.Len(t, accounts, 2)
}
8 changes: 4 additions & 4 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func Test_GetNetworkByNameComplex(t *testing.T) {

network, err = conf.Networks.ByName("testnet")
assert.NoError(t, err)
assert.Equal(t, network.Host, "access.devnet.nodes.onflow.org:9000")
assert.Equal(t, network.Key, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd")
assert.Equal(t, "access.devnet.nodes.onflow.org:9000", network.Host)
assert.Equal(t, "5000676131ad3e22d853a3f75a5b5d0db4236d08dd6612e2baad771014b5266a242bccecc3522ff7207ac357dbe4f225c709d9b273ac484fed5d13976a39bdcd", network.Key)
}

func TestConfig_Validate(t *testing.T) {
Expand Down Expand Up @@ -323,8 +323,8 @@ func TestConfig_Validate(t *testing.T) {
func Test_DefaultConfig(t *testing.T) {
cfg := config.Default()
assert.Len(t, cfg.Emulators, 1)
assert.Equal(t, cfg.Emulators[0].Name, "default")
assert.Equal(t, cfg.Emulators[0].ServiceAccount, "emulator-account")
assert.Equal(t, "default", cfg.Emulators[0].Name)
assert.Equal(t, "emulator-account", cfg.Emulators[0].ServiceAccount)
assert.Len(t, cfg.Networks, 4)
assert.Equal(t, "emulator", cfg.Networks[0].Name)
assert.Equal(t, "testing", cfg.Networks[1].Name)
Expand Down
4 changes: 2 additions & 2 deletions config/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func Test_Deployment(t *testing.T) {

network := deployments.ByNetwork("net")
assert.Len(t, network, 2)
assert.Equal(t, network[0].Account, "acc")
assert.Equal(t, network[1].Account, "acc2")
assert.Equal(t, "acc", network[0].Account)
assert.Equal(t, "acc2", network[1].Account)
})

t.Run("Remove non-existing deployment", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func Test_JSONEnv(t *testing.T) {
conf, loadErr := composer.Load([]string{"test2-flow.json"})

assert.NoError(t, loadErr)
assert.Equal(t, 2, len(conf.Accounts))
assert.Len(t, conf.Accounts, 2)

acc1, _ := conf.Accounts.ByName("advanced")
assert.Equal(t, fmt.Sprintf("0x%s", key2), acc1.Key.PrivateKey.String())
Expand Down
4 changes: 2 additions & 2 deletions config/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestNetworks_AddOrUpdate(t *testing.T) {

// Test adding a new network.
networks.AddOrUpdate(Network{Name: "flow-testnet", Host: "localhost:3570", Key: "flow-testnet-key"})
assert.Equal(t, 2, len(networks))
assert.Len(t, networks, 2)

// Test updating an existing network.
networks.AddOrUpdate(Network{Name: "flow-local", Host: "localhost:3580", Key: "flow-local-key-updated"})
Expand All @@ -70,7 +70,7 @@ func TestNetworks_Remove(t *testing.T) {
// Test removing an existing network.
err := networks.Remove("flow-local")
assert.NoError(t, err)
assert.Equal(t, 1, len(networks))
assert.Len(t, networks, 1)

// Test removing a non-existent network.
err = networks.Remove("flow-mainnet")
Expand Down
28 changes: 14 additions & 14 deletions flowkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ func TestAccounts(t *testing.T) {
ctx,
serviceAcc,
[]accounts.PublicKey{{
Public: pubKey,
Weight: flow.AccountKeyWeightThreshold,
SigAlgo: crypto.ECDSA_P256,
Public: pubKey,
Weight: flow.AccountKeyWeightThreshold,
SigAlgo: crypto.ECDSA_P256,
HashAlgo: crypto.SHA3_256,
}},
)
Expand Down Expand Up @@ -1526,9 +1526,9 @@ func setupAccount(state *State, flowkit Flowkit, account *accounts.Account) {
ctx,
srv,
[]accounts.PublicKey{{
Public: (*pk).PublicKey(),
Weight: flow.AccountKeyWeightThreshold,
SigAlgo: key.SigAlgo(),
Public: (*pk).PublicKey(),
Weight: flow.AccountKeyWeightThreshold,
SigAlgo: key.SigAlgo(),
HashAlgo: key.HashAlgo(),
}},
)
Expand Down Expand Up @@ -1743,9 +1743,9 @@ func TestTransactions_Integration(t *testing.T) {
tx, err := flowkit.BuildTransaction(
ctx,
transactions.AddressesRoles{
Proposer: signer,
Proposer: signer,
Authorizers: []flow.Address{signer},
Payer: signer,
Payer: signer,
},
srvAcc.Key.Index(),
Script{
Expand Down Expand Up @@ -1777,9 +1777,9 @@ func TestTransactions_Integration(t *testing.T) {
tx, err := flowkit.BuildTransaction(
ctx,
transactions.AddressesRoles{
Proposer: a.Address,
Proposer: a.Address,
Authorizers: nil,
Payer: a.Address,
Payer: a.Address,
},
0,
Script{
Expand Down Expand Up @@ -1816,9 +1816,9 @@ func TestTransactions_Integration(t *testing.T) {
tx, err := flowkit.BuildTransaction(
ctx,
transactions.AddressesRoles{
Proposer: a.Address,
Proposer: a.Address,
Authorizers: []flow.Address{a.Address},
Payer: a.Address,
Payer: a.Address,
},
0,
Script{
Expand Down Expand Up @@ -1855,9 +1855,9 @@ func TestTransactions_Integration(t *testing.T) {
tx, err := flowkit.BuildTransaction(
ctx,
transactions.AddressesRoles{
Proposer: a.Address,
Proposer: a.Address,
Authorizers: []flow.Address{a.Address},
Payer: a.Address,
Payer: a.Address,
},
0,
Script{
Expand Down
2 changes: 1 addition & 1 deletion state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func Test_GetContractsByNameComplex(t *testing.T) {

contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork)
require.NoError(t, err)
require.Equal(t, 7, len(contracts))
require.Len(t, contracts, 7)

//sort contracts by name so tests are deterministic
sort.Slice(contracts, func(i, j int) bool {
Expand Down
6 changes: 3 additions & 3 deletions tests/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ func Test_Foo(t *testing.T) {
require.NoError(t, err)

out, _ := rw.ReadFile("test")
assert.Equal(t, out, []byte("foo"))
assert.Equal(t, []byte("foo"), out)

err = rw.WriteFile("test", []byte("bar"), 0644)
require.NoError(t, err)

out, _ = st.ReadFile("test")
assert.Equal(t, out, []byte("bar"))
assert.Equal(t, []byte("bar"), out)
}

func Test_Testnet_ProjectDeploy(t *testing.T) {
Expand Down Expand Up @@ -216,4 +216,4 @@ func Test_Testnet_ProjectDeploy(t *testing.T) {
assert.Equal(t, ContractB.Name, contracts[1].Name)
assert.Equal(t, ContractB.Source, updated)
assert.Equal(t, ContractC.Name, contracts[2].Name)
}
}

0 comments on commit 426cf46

Please sign in to comment.