ethclient: fix flaky pending tx test (#32380)

Fixes: https://github.com/ethereum/go-ethereum/issues/32252
This commit is contained in:
kashitaka 2025-08-11 15:29:07 +09:00 committed by GitHub
parent c3ef6c77c2
commit 8ba1c791bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,6 +110,12 @@ func newTestBackend(config *node.Config) (*node.Node, []*types.Block, error) {
if err != nil {
return nil, nil, fmt.Errorf("can't create new ethereum service: %v", err)
}
// Ensure tx pool starts the background operation
txPool := ethservice.TxPool()
if err = txPool.Sync(); err != nil {
return nil, nil, fmt.Errorf("can't sync transaction pool: %v", err)
}
// Import the test chain.
if err := n.Start(); err != nil {
return nil, nil, fmt.Errorf("can't start test node: %v", err)
@ -506,8 +512,9 @@ func testAtFunctions(t *testing.T, client *rpc.Client) {
}
// send a transaction for some interesting pending status
// and wait for the transaction to be included in the pending block
sendTransaction(ec)
if err := sendTransaction(ec); err != nil {
t.Fatalf("unexpected error: %v", err)
}
// wait for the transaction to be included in the pending block
for {