Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions test/e2e-go/features/participation/participationExpiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
latestRound := fetchLatestRound(fixture, a)

minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(initialRound)
minTxnFee, minAcctBalance, err := fixture.MinFeeAndBalance(latestRound)
a.NoError(err)

transactionFee := minTxnFee
Expand All @@ -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(latestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "")

newAmt, err := sClient.GetBalance(sAccount)
a.NoError(err)
Expand All @@ -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)
Expand Down Expand Up @@ -143,15 +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

_, initialRound = 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(initialRound)
blk, err := sClient.Block(latestRound)
a.NoError(err)
a.Equal(blk.CurrentProtocol, protocolCheck)

sendMoneyTxn := fixture.SendMoneyAndWait(initialRound, amountToSendInitial, transactionFee, richAccount, sAccount, "")
sendMoneyTxn := fixture.SendMoneyAndWait(latestRound, amountToSendInitial, transactionFee, richAccount, sAccount, "")

txnConfirmed = fixture.WaitForTxnConfirmation(initialRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID)
txnConfirmed = fixture.WaitForTxnConfirmation(latestRound+maxRoundsToWaitForTxnConfirm, sAccount, sendMoneyTxn.TxID)
a.True(txnConfirmed)

newAccountStatus, err = pClient.AccountInformation(sAccount)
Expand All @@ -161,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)
Expand Down