From 8bdbf7f3ebd65de9d9c86fbb493874ab6b065fd1 Mon Sep 17 00:00:00 2001 From: kashitaka Date: Sat, 26 Jul 2025 03:08:41 +0900 Subject: [PATCH] ethclient/simulated: Fix flaky rollback test --- ethclient/simulated/rollback_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ethclient/simulated/rollback_test.go b/ethclient/simulated/rollback_test.go index 57c59496d5..c711d97c7e 100644 --- a/ethclient/simulated/rollback_test.go +++ b/ethclient/simulated/rollback_test.go @@ -40,6 +40,7 @@ func TestTransactionRollbackBehavior(t *testing.T) { btx0 := testSendSignedTx(t, testKey, sim, true) tx0 := testSendSignedTx(t, testKey2, sim, false) + time.Sleep(200 * time.Millisecond) // Wait to avoid nonce race condition tx1 := testSendSignedTx(t, testKey2, sim, false) sim.Rollback() @@ -50,6 +51,7 @@ func TestTransactionRollbackBehavior(t *testing.T) { btx2 := testSendSignedTx(t, testKey, sim, true) tx2 := testSendSignedTx(t, testKey2, sim, false) + time.Sleep(200 * time.Millisecond) // Wait to avoid nonce race condition tx3 := testSendSignedTx(t, testKey2, sim, false) sim.Commit() @@ -96,13 +98,13 @@ func pendingStateHasTx(client Client, tx *types.Transaction) bool { ) // Poll for receipt with timeout - deadline := time.Now().Add(2 * time.Second) + deadline := time.Now().Add(200 * time.Millisecond) for time.Now().Before(deadline) { receipt, err = client.TransactionReceipt(ctx, tx.Hash()) if err == nil && receipt != nil { break } - time.Sleep(100 * time.Millisecond) + time.Sleep(5 * time.Millisecond) } if err != nil {