From 67f410a68bf6c23f0704edbfbb3dfe7d332cffe5 Mon Sep 17 00:00:00 2001 From: Jonathan Weiss Date: Mon, 14 Feb 2022 11:44:08 +0200 Subject: [PATCH 1/4] fix: changed misleading variable name --- .../participation/participationExpiration_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e-go/features/participation/participationExpiration_test.go b/test/e2e-go/features/participation/participationExpiration_test.go index ae1a7aabf5..f2e4fffa1f 100644 --- a/test/e2e-go/features/participation/participationExpiration_test.go +++ b/test/e2e-go/features/participation/participationExpiration_test.go @@ -46,9 +46,9 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f accountList, err := fixture.GetWalletsSortedByBalance() a.NoError(err) richAccount := accountList[0].Address - _, initialRound := fixture.GetBalanceAndRound(richAccount) + _, richAccountLatestRound := fixture.GetBalanceAndRound(richAccount) - minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(initialRound) + minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(richAccountLatestRound) a.NoError(err) transactionFee := minTxnFee @@ -57,7 +57,7 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f initialAmt, err := sClient.GetBalance(sAccount) a.NoError(err) - fixture.SendMoneyAndWait(initialRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") + fixture.SendMoneyAndWait(richAccountLatestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") newAmt, err := sClient.GetBalance(sAccount) a.NoError(err) @@ -143,15 +143,15 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f // Now we want to send a transaction to the account and test that // it was taken offline after we sent it something - _, initialRound = fixture.GetBalanceAndRound(richAccount) + _, richAccountLatestRound = fixture.GetBalanceAndRound(richAccount) - blk, err := sClient.Block(initialRound) + blk, err := sClient.Block(richAccountLatestRound) a.NoError(err) a.Equal(blk.CurrentProtocol, protocolCheck) - sendMoneyTxn := fixture.SendMoneyAndWait(initialRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") + sendMoneyTxn := fixture.SendMoneyAndWait(richAccountLatestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") - txnConfirmed = fixture.WaitForTxnConfirmation(initialRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID) + txnConfirmed = fixture.WaitForTxnConfirmation(richAccountLatestRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID) a.True(txnConfirmed) newAccountStatus, err = pClient.AccountInformation(sAccount) From 49c9289f099724c489b167908bb00cb70105e5c8 Mon Sep 17 00:00:00 2001 From: Jonathan Weiss Date: Mon, 14 Feb 2022 11:54:50 +0200 Subject: [PATCH 2/4] fix: syncing between the two clients --- .../features/participation/participationExpiration_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/e2e-go/features/participation/participationExpiration_test.go b/test/e2e-go/features/participation/participationExpiration_test.go index f2e4fffa1f..142f72a15a 100644 --- a/test/e2e-go/features/participation/participationExpiration_test.go +++ b/test/e2e-go/features/participation/participationExpiration_test.go @@ -145,6 +145,10 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f _, richAccountLatestRound = fixture.GetBalanceAndRound(richAccount) + // making certain sClient has the same blocks as pClient. + _, err = sClient.WaitForRound(richAccountLatestRound) + a.NoError(err) + blk, err := sClient.Block(richAccountLatestRound) a.NoError(err) a.Equal(blk.CurrentProtocol, protocolCheck) From c2ff22fb39759b559411493f4d90b55809d75906 Mon Sep 17 00:00:00 2001 From: Jonathan Weiss Date: Mon, 14 Feb 2022 16:58:29 +0200 Subject: [PATCH 3/4] fix: aligning the round number between both clients --- .../features/participation/participationExpiration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e-go/features/participation/participationExpiration_test.go b/test/e2e-go/features/participation/participationExpiration_test.go index 142f72a15a..48d65a20d4 100644 --- a/test/e2e-go/features/participation/participationExpiration_test.go +++ b/test/e2e-go/features/participation/participationExpiration_test.go @@ -146,7 +146,7 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f _, richAccountLatestRound = fixture.GetBalanceAndRound(richAccount) // making certain sClient has the same blocks as pClient. - _, err = sClient.WaitForRound(richAccountLatestRound) + _, err = sClient.WaitForRound(uint64(lastValidRound + 1)) a.NoError(err) blk, err := sClient.Block(richAccountLatestRound) From 8a2c0d4255163373e9d0b16ddbb5327f92e98160 Mon Sep 17 00:00:00 2001 From: Jonathan Weiss Date: Mon, 14 Feb 2022 18:11:15 +0200 Subject: [PATCH 4/4] getting state instead of balance and round --- .../participationExpiration_test.go | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/e2e-go/features/participation/participationExpiration_test.go b/test/e2e-go/features/participation/participationExpiration_test.go index 48d65a20d4..126b5acf09 100644 --- a/test/e2e-go/features/participation/participationExpiration_test.go +++ b/test/e2e-go/features/participation/participationExpiration_test.go @@ -46,9 +46,9 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f accountList, err := fixture.GetWalletsSortedByBalance() a.NoError(err) richAccount := accountList[0].Address - _, richAccountLatestRound := fixture.GetBalanceAndRound(richAccount) + latestRound := fetchLatestRound(fixture, a) - minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(richAccountLatestRound) + minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(latestRound) a.NoError(err) transactionFee := minTxnFee @@ -57,7 +57,7 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f initialAmt, err := sClient.GetBalance(sAccount) a.NoError(err) - fixture.SendMoneyAndWait(richAccountLatestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") + fixture.SendMoneyAndWait(latestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") newAmt, err := sClient.GetBalance(sAccount) a.NoError(err) @@ -73,7 +73,8 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f startTime := time.Now() for time.Since(startTime) < 2*time.Minute { - _, currentRound := fixture.GetBalanceAndRound(richAccount) + currentRound := fetchLatestRound(fixture, a) + // account adds part key partKeyFirstValid := uint64(0) partKeyValidityPeriod := uint64(10) @@ -143,19 +144,19 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f // Now we want to send a transaction to the account and test that // it was taken offline after we sent it something - _, richAccountLatestRound = fixture.GetBalanceAndRound(richAccount) + latestRound = fetchLatestRound(fixture, a) // making certain sClient has the same blocks as pClient. _, err = sClient.WaitForRound(uint64(lastValidRound + 1)) a.NoError(err) - blk, err := sClient.Block(richAccountLatestRound) + blk, err := sClient.Block(latestRound) a.NoError(err) a.Equal(blk.CurrentProtocol, protocolCheck) - sendMoneyTxn := fixture.SendMoneyAndWait(richAccountLatestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") + sendMoneyTxn := fixture.SendMoneyAndWait(latestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "") - txnConfirmed = fixture.WaitForTxnConfirmation(richAccountLatestRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID) + txnConfirmed = fixture.WaitForTxnConfirmation(latestRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID) a.True(txnConfirmed) newAccountStatus, err = pClient.AccountInformation(sAccount) @@ -165,6 +166,12 @@ func testExpirationAccounts(t *testing.T, fixture *fixtures.RestClientFixture, f a.Equal(finalStatus.String(), newAccountStatus.Status) } +func fetchLatestRound(fixture *fixtures.RestClientFixture, a *require.Assertions) uint64 { + status, err := fixture.LibGoalClient.Status() + a.NoError(err) + return status.LastRound +} + // TestParticipationAccountsExpirationFuture tests that sending a transaction to an account with // its last valid round being less than the current round will turn it offline. This test will only // work when the consensus protocol enables it (in this case the future protocol)