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 { if err != nil {
return nil, nil, fmt.Errorf("can't create new ethereum service: %v", err) 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. // Import the test chain.
if err := n.Start(); err != nil { if err := n.Start(); err != nil {
return nil, nil, fmt.Errorf("can't start test node: %v", err) 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 // send a transaction for some interesting pending status
// and wait for the transaction to be included in the pending block if err := sendTransaction(ec); err != nil {
sendTransaction(ec) t.Fatalf("unexpected error: %v", err)
}
// wait for the transaction to be included in the pending block // wait for the transaction to be included in the pending block
for { for {