Skip to content

Commit 8ba1c79

Browse files
authored
ethclient: fix flaky pending tx test (#32380)
Fixes: #32252
1 parent c3ef6c7 commit 8ba1c79

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ethclient/ethclient_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func newTestBackend(config *node.Config) (*node.Node, []*types.Block, error) {
110110
if err != nil {
111111
return nil, nil, fmt.Errorf("can't create new ethereum service: %v", err)
112112
}
113+
// Ensure tx pool starts the background operation
114+
txPool := ethservice.TxPool()
115+
if err = txPool.Sync(); err != nil {
116+
return nil, nil, fmt.Errorf("can't sync transaction pool: %v", err)
117+
}
118+
113119
// Import the test chain.
114120
if err := n.Start(); err != nil {
115121
return nil, nil, fmt.Errorf("can't start test node: %v", err)
@@ -506,8 +512,9 @@ func testAtFunctions(t *testing.T, client *rpc.Client) {
506512
}
507513

508514
// send a transaction for some interesting pending status
509-
// and wait for the transaction to be included in the pending block
510-
sendTransaction(ec)
515+
if err := sendTransaction(ec); err != nil {
516+
t.Fatalf("unexpected error: %v", err)
517+
}
511518

512519
// wait for the transaction to be included in the pending block
513520
for {

0 commit comments

Comments
 (0)