diff --git a/pkg/tests/combined_account_transition_test.go b/pkg/tests/combined_account_transition_test.go index ef85d873c..a30f4057c 100644 --- a/pkg/tests/combined_account_transition_test.go +++ b/pkg/tests/combined_account_transition_test.go @@ -48,32 +48,32 @@ func Test_AccountStateTransition(t *testing.T) { ts.AssertTransactionsInCacheAccepted(wallet.Transactions("TX1"), true, node1, node2) } - // create the account1 from TX1:0 with wallet "first" + // create the account-1 from TX1:0 with wallet "account-1" // generated (block1, TX2) - ts.AddWallet("first", node1, iotago.EmptyAccountID) + ts.AddWallet("account-1", node1, iotago.EmptyAccountID) createFullAccount(ts) - // create the account2, from implicit to full account from TX1:1 with wallet "second" + // create the account-2, from implicit to full account from TX1:1 with wallet "account-2" // generated (block2, TX3), (block3, TX4) - ts.AddWallet("second", node1, iotago.EmptyAccountID) + ts.AddWallet("account-2", node1, iotago.EmptyAccountID) account2ID := createImplicitToFullAccount(ts) - // send funds to account2, with TX1:2 + // send funds to account-2, with TX1:2 // generated (block4, TX5) sendFunds(ts) - // allot 1000 mana to account2 with TX1:3 + // allot 1000 mana to account-2 with TX1:3 // generated (block5, TX6) allotManaTo(ts, account2ID) - // create native token from "TX5:0" and account2 (TX4:0) + // create native token from "TX5:0" and account-2 (TX4:0) // generated (block6, TX7) createNativetoken(ts) } func createFullAccount(ts *testsuite.TestSuite) iotago.AccountID { node1 := ts.Node("node1") - newUserWallet := ts.Wallet("first") + newUserWallet := ts.Wallet("account-1") // CREATE NEW ACCOUNT WITH BLOCK ISSUER FROM BASIC UTXO newAccountBlockIssuerKey := tpkg.RandBlockIssuerKey() @@ -125,7 +125,7 @@ func createFullAccount(ts *testsuite.TestSuite) iotago.AccountID { func createImplicitToFullAccount(ts *testsuite.TestSuite) iotago.AccountID { node1 := ts.Node("node1") - newUserWallet := ts.Wallet("second") + newUserWallet := ts.Wallet("account-2") // CREATE IMPLICIT ACCOUNT FROM GENESIS BASIC UTXO, SENT TO A NEW USER WALLET. // a default wallet, already registered in the ledger, will issue the transaction and block. @@ -198,7 +198,7 @@ func sendFunds(ts *testsuite.TestSuite) { node1 := ts.Node("node1") node2 := ts.Node("node2") wallet := ts.DefaultWallet() - secondWallet := ts.Wallet("second") + secondWallet := ts.Wallet("account-2") // send funds from defaultWallet to secondWallet tx := wallet.SendFundsToWallet("TX5", secondWallet, "TX1:2") @@ -246,7 +246,7 @@ func allotManaTo(ts *testsuite.TestSuite, to iotago.AccountID) { // createNativetoken creates a native token from the given input and account. func createNativetoken(ts *testsuite.TestSuite) { - wallet := ts.Wallet("second") + wallet := ts.Wallet("account-2") node1 := ts.Node("node1") node2 := ts.Node("node2") diff --git a/tools/docker-network/tests/accounttransition_test.go b/tools/docker-network/tests/accounttransition_test.go index 6efc0bcc2..a8fa74f33 100644 --- a/tools/docker-network/tests/accounttransition_test.go +++ b/tools/docker-network/tests/accounttransition_test.go @@ -12,10 +12,10 @@ import ( ) // Test_AccountTransitions follows the account state transition flow described in: -// 1. Create account1. -// 2. Create account2. -// 3. account1 requests faucet funds then allots 1000 mana to account2. -// 4. account2 requests faucet funds then creates native tokens. +// 1. Create account-1. +// 2. Create account-2. +// 3. account-1 requests faucet funds then allots 1000 mana to account-2. +// 4. account-2 requests faucet funds then creates native tokens. func Test_AccountTransitions(t *testing.T) { d := dockertestframework.NewDockerTestFramework(t, dockertestframework.WithProtocolParametersOptions(dockertestframework.ShortSlotsAndEpochsProtocolParametersOptions...), @@ -33,16 +33,16 @@ func Test_AccountTransitions(t *testing.T) { d.WaitUntilNetworkReady() - // create account1 - fmt.Println("Creating account1") - wallet1, _ := d.CreateAccountFromFaucet() + // create account-1 + fmt.Println("Creating account-1") + wallet1, _ := d.CreateAccountFromFaucet("account-1") - // create account2 - fmt.Println("Creating account2") - wallet2, _ := d.CreateAccountFromFaucet() + // create account-2 + fmt.Println("Creating account-2") + wallet2, _ := d.CreateAccountFromFaucet("account-2") - // allot 1000 mana from account1 to account2 - fmt.Println("Allotting mana from account1 to account2") + // allot 1000 mana from account-1 to account-2 + fmt.Println("Allotting mana from account-1 to account-2") d.RequestFaucetFundsAndAllotManaTo(wallet1, wallet2.BlockIssuer.AccountData, 1000) // create native token diff --git a/tools/docker-network/tests/api_core_test.go b/tools/docker-network/tests/api_core_test.go index d9ad30c4c..717c526fe 100644 --- a/tools/docker-network/tests/api_core_test.go +++ b/tools/docker-network/tests/api_core_test.go @@ -206,7 +206,7 @@ func prepareAssets(d *dockertestframework.DockerTestFramework, totalAssetsNum in for i := 0; i < totalAssetsNum; i++ { // account - wallet, account := d.CreateAccountFromFaucet() + wallet, account := d.CreateAccountFromFaucet(fmt.Sprintf("account-%d", i)) assets.setupAssetsForSlot(account.OutputID.Slot()) assets[account.OutputID.Slot()].accountAddress = account.Address diff --git a/tools/docker-network/tests/committeerotation_test.go b/tools/docker-network/tests/committeerotation_test.go index db4daff1f..3e022ffd7 100644 --- a/tools/docker-network/tests/committeerotation_test.go +++ b/tools/docker-network/tests/committeerotation_test.go @@ -217,7 +217,7 @@ func Test_Staking(t *testing.T) { t.Cleanup(cancel) // create implicit account for the validator - implicitAccount := d.CreateImplicitAccount(ctx) + implicitAccount := d.CreateImplicitAccount(ctx, "account-1") blockIssuance := implicitAccount.Wallet().GetNewBlockIssuanceResponse() @@ -266,7 +266,7 @@ func Test_Delegation(t *testing.T) { d.WaitUntilNetworkReady() // create an account to perform delegation - wallet, _ := d.CreateAccountFromFaucet() + wallet, _ := d.CreateAccountFromFaucet("account-1") // delegate all faucet funds to V2, V2 should replace V3 //nolint:forcetypeassert diff --git a/tools/docker-network/tests/dockertestframework/accounts.go b/tools/docker-network/tests/dockertestframework/accounts.go index 82fc7f2ef..8f920652e 100644 --- a/tools/docker-network/tests/dockertestframework/accounts.go +++ b/tools/docker-network/tests/dockertestframework/accounts.go @@ -74,8 +74,8 @@ func (i *ImplicitAccount) OutputData() *mock.OutputData { } // CreateImplicitAccount requests faucet funds and creates an implicit account. It already wait until the transaction is committed and the created account is useable. -func (d *DockerTestFramework) CreateImplicitAccount(ctx context.Context) *ImplicitAccount { - wallet := mock.NewWallet(d.Testing, "", d.defaultWallet.Client, &DockerWalletClock{client: d.defaultWallet.Client}) +func (d *DockerTestFramework) CreateImplicitAccount(ctx context.Context, name string) *ImplicitAccount { + wallet := mock.NewWallet(d.Testing, name, d.defaultWallet.Client, &DockerWalletClock{client: d.defaultWallet.Client}) outputData := d.RequestFaucetFunds(ctx, wallet, iotago.AddressImplicitAccountCreation) accountID := iotago.AccountIDFromOutputID(outputData.ID) @@ -99,7 +99,7 @@ func (d *DockerTestFramework) CreateImplicitAccount(ctx context.Context) *Implic } } -func (d *DockerTestFramework) CreateImplicitAccounts(ctx context.Context, count int) []*ImplicitAccount { +func (d *DockerTestFramework) CreateImplicitAccounts(ctx context.Context, count int, names ...string) []*ImplicitAccount { var wg sync.WaitGroup implicitAccounts := make([]*ImplicitAccount, count) @@ -112,7 +112,11 @@ func (d *DockerTestFramework) CreateImplicitAccounts(ctx context.Context, count defer wg.Done() // create implicit accounts - implicitAccounts[nr] = d.CreateImplicitAccount(ctx) + name := fmt.Sprintf("account-%d", nr) + if len(names) > nr { + name = names[nr] + } + implicitAccounts[nr] = d.CreateImplicitAccount(ctx, name) }(i) } @@ -171,10 +175,10 @@ func (d *DockerTestFramework) CreateAccountFromImplicitAccount(implicitAccount * // CreateAccountFromFaucet creates a new account by requesting faucet funds to an implicit account address and then transitioning the new output to a full account output. // It already waits until the transaction is committed and the created account is useable. -func (d *DockerTestFramework) CreateAccountFromFaucet() (*mock.Wallet, *mock.AccountData) { +func (d *DockerTestFramework) CreateAccountFromFaucet(name string) (*mock.Wallet, *mock.AccountData) { ctx := context.TODO() - implicitAccount := d.CreateImplicitAccount(ctx) + implicitAccount := d.CreateImplicitAccount(ctx, name) accountData, signedTx, block := d.TransitionImplicitAccountToAccountOutputBlock(implicitAccount, d.defaultWallet.GetNewBlockIssuanceResponse()) diff --git a/tools/docker-network/tests/eventapi_test.go b/tools/docker-network/tests/eventapi_test.go index 8c89843cd..7effe509d 100644 --- a/tools/docker-network/tests/eventapi_test.go +++ b/tools/docker-network/tests/eventapi_test.go @@ -125,7 +125,7 @@ func test_BasicTaggedDataBlocks(t *testing.T, e *dockertestframework.EventAPIDoc defer eventClt.Close() // create an account to issue blocks - wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet() + wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet("account-basic-tagged-data") // prepare data blocks to send expectedBlocks := make(map[string]*iotago.Block) @@ -177,7 +177,7 @@ func test_DelegationTransactionBlocks(t *testing.T, e *dockertestframework.Event defer eventClt.Close() // create an account to issue blocks - wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet() + wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet("account-delegation") fundsOutputData := e.DockerTestFramework().RequestFaucetFunds(ctx, wallet, iotago.AddressEd25519) // prepare data blocks to send @@ -243,7 +243,7 @@ func test_AccountTransactionBlocks(t *testing.T, e *dockertestframework.EventAPI // implicit account transition { // create an implicit account by requesting faucet funds - implicitAccount := e.DockerTestFramework().CreateImplicitAccount(ctx) + implicitAccount := e.DockerTestFramework().CreateImplicitAccount(ctx, "account-tx-blocks") // prepare account transition block accountData, _, blk := e.DockerTestFramework().TransitionImplicitAccountToAccountOutputBlock(implicitAccount, implicitAccount.Wallet().GetNewBlockIssuanceResponse()) @@ -308,7 +308,7 @@ func test_FoundryTransactionBlocks(t *testing.T, e *dockertestframework.EventAPI defer eventClt.Close() { - wallet, account := e.DockerTestFramework().CreateAccountFromFaucet() + wallet, account := e.DockerTestFramework().CreateAccountFromFaucet("account-foundry") fundsOutputData := e.DockerTestFramework().RequestFaucetFunds(ctx, wallet, iotago.AddressEd25519) // prepare foundry output block @@ -373,7 +373,7 @@ func test_NFTTransactionBlocks(t *testing.T, e *dockertestframework.EventAPIDock defer eventClt.Close() { - wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet() + wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet("account-nft") fundsOutputData := e.DockerTestFramework().RequestFaucetFunds(ctx, wallet, iotago.AddressEd25519) // prepare NFT output block @@ -436,7 +436,7 @@ func test_BlockMetadataMatchedCoreAPI(t *testing.T, e *dockertestframework.Event defer eventClt.Close() { - wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet() + wallet, _ := e.DockerTestFramework().CreateAccountFromFaucet("account-block-metadata") assertions := []func(){ func() { e.AssertBlockMetadataStateAcceptedBlocks(ctx, eventClt) }, diff --git a/tools/docker-network/tests/mempool_invalid_signatures_test.go b/tools/docker-network/tests/mempool_invalid_signatures_test.go index c6371be51..97e13c7b8 100644 --- a/tools/docker-network/tests/mempool_invalid_signatures_test.go +++ b/tools/docker-network/tests/mempool_invalid_signatures_test.go @@ -32,7 +32,7 @@ func Test_MempoolInvalidSignatures(t *testing.T) { d.WaitUntilNetworkReady() - wallet, _ := d.CreateAccountFromFaucet() + wallet, _ := d.CreateAccountFromFaucet("account-1") ctx := context.Background() fundsOutputData := d.RequestFaucetFunds(ctx, wallet, iotago.AddressEd25519) diff --git a/tools/docker-network/tests/rewards_test.go b/tools/docker-network/tests/rewards_test.go index 979d22cb9..b779b5a6a 100644 --- a/tools/docker-network/tests/rewards_test.go +++ b/tools/docker-network/tests/rewards_test.go @@ -54,7 +54,7 @@ func Test_ValidatorRewards(t *testing.T) { // create two implicit accounts for "good" and "lazy" validator validatorCount := 2 - implicitAccounts := d.CreateImplicitAccounts(ctx, validatorCount) + implicitAccounts := d.CreateImplicitAccounts(ctx, validatorCount, "goodValidator", "lazyValidator") blockIssuance, err := clt.BlockIssuance(ctx) require.NoError(t, err) @@ -168,7 +168,7 @@ func Test_DelegatorRewards(t *testing.T) { d.WaitUntilNetworkReady() ctx := context.Background() - delegatorWallet, _ := d.CreateAccountFromFaucet() + delegatorWallet, _ := d.CreateAccountFromFaucet("account-1") clt := delegatorWallet.Client // delegate funds to V2 @@ -230,7 +230,7 @@ func Test_DelayedClaimingRewards(t *testing.T) { d.WaitUntilNetworkReady() ctx := context.Background() - delegatorWallet, _ := d.CreateAccountFromFaucet() + delegatorWallet, _ := d.CreateAccountFromFaucet("account-1") clt := delegatorWallet.Client { diff --git a/tools/docker-network/tests/sync_snapshot_test.go b/tools/docker-network/tests/sync_snapshot_test.go index b4d114362..f3c2c3da5 100644 --- a/tools/docker-network/tests/sync_snapshot_test.go +++ b/tools/docker-network/tests/sync_snapshot_test.go @@ -40,8 +40,8 @@ func Test_SyncFromSnapshot(t *testing.T) { ctx := context.Background() clt := d.DefaultWallet().Client - createAccountAndDelegateTo := func(receiver *dockertestframework.Node) (*mock.Wallet, *mock.AccountData, *mock.OutputData) { - delegatorWallet, accountData := d.CreateAccountFromFaucet() + createAccountAndDelegateTo := func(receiver *dockertestframework.Node, name string) (*mock.Wallet, *mock.AccountData, *mock.OutputData) { + delegatorWallet, accountData := d.CreateAccountFromFaucet(name) clt := delegatorWallet.Client // delegate funds to receiver @@ -56,8 +56,8 @@ func Test_SyncFromSnapshot(t *testing.T) { return delegatorWallet, accountData, delegationOutputData } - v1DelegatorWallet, v1DelegatorAccountData, v1DelegationOutputData := createAccountAndDelegateTo(d.Node("V1")) - v2DelegatorWallet, v2DelegatorAccountData, v2DelegationOutputData := createAccountAndDelegateTo(d.Node("V2")) + v1DelegatorWallet, v1DelegatorAccountData, v1DelegationOutputData := createAccountAndDelegateTo(d.Node("V1"), "account-1") + v2DelegatorWallet, v2DelegatorAccountData, v2DelegationOutputData := createAccountAndDelegateTo(d.Node("V2"), "account-2") //nolint:forcetypeassert currentEpoch := clt.CommittedAPI().TimeProvider().CurrentEpoch() @@ -117,7 +117,7 @@ func Test_SyncFromSnapshot(t *testing.T) { require.NoError(t, err) // create V3 delegator, the committee should change to V1, V3, V4 - v3DelegatorWallet, v3DelegatorAccountData, v3DelegationOutputData := createAccountAndDelegateTo(d.Node("V3")) + v3DelegatorWallet, v3DelegatorAccountData, v3DelegationOutputData := createAccountAndDelegateTo(d.Node("V3"), "account-3") currentEpoch = clt.CommittedAPI().TimeProvider().CurrentEpoch() expectedEpoch = v3DelegationOutputData.Output.(*iotago.DelegationOutput).StartEpoch + 1 for range expectedEpoch - currentEpoch {