Skip to content

Commit

Permalink
Reorder round query and transaction sending. (#3049)
Browse files Browse the repository at this point in the history
## Summary

The test had a conceptual buggy pattern. It was using 
```golang
round, err = client.CurrentRound()
...
_, err = client.BroadcastTransaction(signedTxn)
...
_, err = client.WaitForRound(round + 3)
```
which is doomed to fail if the test process goes to sleep for a minute between the `client.CurrentRound()` call and the `client.BroadcastTransaction` call. The trivial solution is to reorder the calls so that 
```golang
_, err = client.BroadcastTransaction(signedTxn)
...
round, err = client.CurrentRound()
...
_, err = client.WaitForRound(round + 3)
```


## Test Plan

This is a test.
  • Loading branch information
tsachiherman authored Oct 13, 2021
1 parent c4bfc26 commit 3572e1f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/e2e-go/features/transactions/accountv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ func TestAccountInformationV2(t *testing.T) {

fee := uint64(1000)

round, err := client.CurrentRound()
a.NoError(err)

// Fund the manager, so it can issue transactions later on
_, err = client.SendPaymentFromUnencryptedWallet(creator, user, fee, 10000000000, nil)
a.NoError(err)

round, err := client.CurrentRound()
a.NoError(err)
client.WaitForRound(round + 4)

// There should be no apps to start with
Expand Down Expand Up @@ -165,10 +165,10 @@ int 1
a.NoError(err)
signedTxn, err := client.SignTransactionWithWallet(wh, nil, tx)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
txid, err := client.BroadcastTransaction(signedTxn)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
// ensure transaction is accepted into a block within 5 rounds.
confirmed := fixture.WaitForAllTxnsToConfirm(round+5, map[string]string{txid: signedTxn.Txn.Sender.String()})
a.True(confirmed)
Expand Down Expand Up @@ -214,10 +214,10 @@ int 1
a.NoError(err)
signedTxn, err = client.SignTransactionWithWallet(wh, nil, tx)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
txid, err = client.BroadcastTransaction(signedTxn)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
_, err = client.WaitForRound(round + 3)
a.NoError(err)
// Ensure the txn committed
Expand Down Expand Up @@ -285,10 +285,10 @@ int 1
a.NoError(err)
signedTxn, err = client.SignTransactionWithWallet(wh, nil, tx)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
_, err = client.BroadcastTransaction(signedTxn)
a.NoError(err)
round, err = client.CurrentRound()
a.NoError(err)
_, err = client.WaitForRound(round + 2)
a.NoError(err)
// Ensure the txn committed
Expand Down

0 comments on commit 3572e1f

Please sign in to comment.