Skip to content

Commit

Permalink
end2endtest: fix race in tokentxs introduced in #1121
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Oct 16, 2023
1 parent 0fd72e8 commit 7e6a1d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/end2endtest/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ func testSendTokens(api *apiclient.HTTPclient, aliceKeys, bobKeys *ethereum.Sign

// send a couple of token txs to increase the nonce, without waiting for them to be mined
// this tests that the mempool transactions are properly ordered.
wg := sync.WaitGroup{}
var wg sync.WaitGroup
wg.Add(1)
go func() {
log.Warnf("send transactions with nonce+1, should not be mined before the others")
// send 1 token to burn address with nonce + 1 (should be mined after the other txs)
if _, err = alice.TransferWithNonce(state.BurnAddress, 1, aliceAcc.Nonce+1); err != nil {
if _, err := alice.TransferWithNonce(state.BurnAddress, 1, aliceAcc.Nonce+1); err != nil {
log.Fatalf("cannot burn tokens: %v", err)
}
if _, err = bob.TransferWithNonce(state.BurnAddress, 1, bobAcc.Nonce+1); err != nil {
if _, err := bob.TransferWithNonce(state.BurnAddress, 1, bobAcc.Nonce+1); err != nil {
log.Fatalf("cannot burn tokens: %v", err)
}
wg.Done()
Expand All @@ -208,6 +208,7 @@ func testSendTokens(api *apiclient.HTTPclient, aliceKeys, bobKeys *ethereum.Sign
var txhasha, txhashb []byte
wg.Add(1)
go func() {
var err error
txhasha, err = alice.TransferWithNonce(bobKeys.Address(), amountAtoB, aliceAcc.Nonce)
if err != nil {
log.Fatalf("cannot send tokens: %v", err)
Expand Down

0 comments on commit 7e6a1d7

Please sign in to comment.