mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
ethclient/simulated: Fix flaky rollback test
This commit is contained in:
parent
b369a855fb
commit
8bdbf7f3eb
1 changed files with 4 additions and 2 deletions
|
|
@ -40,6 +40,7 @@ func TestTransactionRollbackBehavior(t *testing.T) {
|
||||||
|
|
||||||
btx0 := testSendSignedTx(t, testKey, sim, true)
|
btx0 := testSendSignedTx(t, testKey, sim, true)
|
||||||
tx0 := testSendSignedTx(t, testKey2, sim, false)
|
tx0 := testSendSignedTx(t, testKey2, sim, false)
|
||||||
|
time.Sleep(200 * time.Millisecond) // Wait to avoid nonce race condition
|
||||||
tx1 := testSendSignedTx(t, testKey2, sim, false)
|
tx1 := testSendSignedTx(t, testKey2, sim, false)
|
||||||
|
|
||||||
sim.Rollback()
|
sim.Rollback()
|
||||||
|
|
@ -50,6 +51,7 @@ func TestTransactionRollbackBehavior(t *testing.T) {
|
||||||
|
|
||||||
btx2 := testSendSignedTx(t, testKey, sim, true)
|
btx2 := testSendSignedTx(t, testKey, sim, true)
|
||||||
tx2 := testSendSignedTx(t, testKey2, sim, false)
|
tx2 := testSendSignedTx(t, testKey2, sim, false)
|
||||||
|
time.Sleep(200 * time.Millisecond) // Wait to avoid nonce race condition
|
||||||
tx3 := testSendSignedTx(t, testKey2, sim, false)
|
tx3 := testSendSignedTx(t, testKey2, sim, false)
|
||||||
|
|
||||||
sim.Commit()
|
sim.Commit()
|
||||||
|
|
@ -96,13 +98,13 @@ func pendingStateHasTx(client Client, tx *types.Transaction) bool {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Poll for receipt with timeout
|
// Poll for receipt with timeout
|
||||||
deadline := time.Now().Add(2 * time.Second)
|
deadline := time.Now().Add(200 * time.Millisecond)
|
||||||
for time.Now().Before(deadline) {
|
for time.Now().Before(deadline) {
|
||||||
receipt, err = client.TransactionReceipt(ctx, tx.Hash())
|
receipt, err = client.TransactionReceipt(ctx, tx.Hash())
|
||||||
if err == nil && receipt != nil {
|
if err == nil && receipt != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(5 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue