Skip to content

Commit

Permalink
test(geometric txmgr): added parallel test that sends nonces in rever…
Browse files Browse the repository at this point in the history
…se order
  • Loading branch information
samlaf committed Aug 9, 2024
1 parent 3a12fcc commit 549b045
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions chainio/txmgr/geometric/geometric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,36 @@ func TestGeometricTxManager(t *testing.T) {

})

t.Run("Send n=3 txs in parallel, with nonces in reverse order", func(t *testing.T) {
n := 3
h := newTestHarness(t, nil)

g := new(errgroup.Group)

txs := make([]*types.Transaction, n)
txReceipts := make([]*types.Receipt, n)

for nonce := n - 1; nonce >= 0; nonce-- {
tx := newUnsignedEthTransferTx(uint64(nonce), nil)
txs[nonce] = tx
nonce := nonce
g.Go(func() error {
ctxWithTimeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
txReceipt, err := h.txmgr.Send(ctxWithTimeout, tx)
if err == nil {
txReceipts[nonce] = txReceipt
}
return err
})
time.Sleep(1 * time.Second)
}

err := g.Wait()
require.NoError(t, err)

})

t.Run("Send n=3 txs sequentially", func(t *testing.T) {
n := uint64(3)
h := newTestHarness(t, nil)
Expand Down

0 comments on commit 549b045

Please sign in to comment.