Skip to content

Commit

Permalink
tests: Fix restClientFixture test flaking (#4484)
Browse files Browse the repository at this point in the history
Many e2e tests spins up 2 nodes, Node A and Node B: A observes it is currently round r, but  B is still on round r-1.
Node A then sends a tx with validity range (r, r+1000), and B then discards the tx since r-1 is outside
of the tx’s validity range.
Fixed by changing the validity window for transactions with default validity.
  • Loading branch information
nicholasguoalgorand authored Aug 29, 2022
1 parent 9e4e84c commit 63ddd47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ func TestRewardRateRecalculation(t *testing.T) {
r.NoError(err)
minFee, minBal, err := fixture.MinFeeAndBalance(curStatus.LastRound)
r.NoError(err)
deadline := curStatus.LastRound + uint64(5)
fixture.SendMoneyAndWait(deadline, amountToSend, minFee, richAccount.Address, rewardsAccount, "")
fixture.SendMoneyAndWait(curStatus.LastRound, amountToSend, minFee, richAccount.Address, rewardsAccount, "")

blk, err := client.Block(curStatus.LastRound)
r.NoError(err)
Expand All @@ -373,8 +372,7 @@ func TestRewardRateRecalculation(t *testing.T) {

curStatus, err = client.Status()
r.NoError(err)
deadline = curStatus.LastRound + uint64(5)
fixture.SendMoneyAndWait(deadline, amountToSend, minFee, richAccount.Address, rewardsAccount, "")
fixture.SendMoneyAndWait(curStatus.LastRound, amountToSend, minFee, richAccount.Address, rewardsAccount, "")

rewardRecalcRound = rewardRecalcRound + consensusParams.RewardsRateRefreshInterval

Expand Down
4 changes: 3 additions & 1 deletion test/framework/fixtures/restClientFixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package fixtures

import (
"fmt"
"github.com/algorand/go-algorand/data/basics"
"sort"
"time"
"unicode"
Expand Down Expand Up @@ -328,7 +329,8 @@ func (f *RestClientFixture) SendMoneyAndWait(curRound, amountToSend, transaction
// SendMoneyAndWaitFromWallet is as above, but for a specific wallet
func (f *RestClientFixture) SendMoneyAndWaitFromWallet(walletHandle, walletPassword []byte, curRound, amountToSend, transactionFee uint64, fromAccount, toAccount string, closeToAccount string) (txn v1.Transaction) {
client := f.LibGoalClient
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, 0, 0)
// use one curRound - 1 in case other nodes are behind
fundingTx, err := client.SendPaymentFromWallet(walletHandle, walletPassword, fromAccount, toAccount, transactionFee, amountToSend, nil, closeToAccount, basics.Round(curRound).SubSaturate(1), 0)
require.NoError(f.t, err, "client should be able to send money from rich to poor account")
require.NotEmpty(f.t, fundingTx.ID().String(), "transaction ID should not be empty")
waitingDeadline := curRound + uint64(5)
Expand Down

0 comments on commit 63ddd47

Please sign in to comment.