From 1f11d2d3402730fca32b37e1f3c012cd5bf7fc55 Mon Sep 17 00:00:00 2001 From: Kero Date: Tue, 17 Oct 2023 20:09:48 +0800 Subject: [PATCH] ethclient: ensure the close of canceled context (#28349) --- ethclient/ethclient_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ethclient/ethclient_test.go b/ethclient/ethclient_test.go index d2f371093..beaa4240a 100644 --- a/ethclient/ethclient_test.go +++ b/ethclient/ethclient_test.go @@ -393,6 +393,7 @@ func testTransactionInBlockInterrupted(t *testing.T, client *rpc.Client) { // Test tx in block interrupted. ctx, cancel := context.WithCancel(context.Background()) cancel() + <-ctx.Done() // Ensure the close of the Done channel tx, err := ec.TransactionInBlock(ctx, block.Hash(), 0) if tx != nil { t.Fatal("transaction should be nil") @@ -666,6 +667,7 @@ func testTransactionSender(t *testing.T, client *rpc.Client) { // TransactionSender. Ensure the server is not asked by canceling the context here. canceledCtx, cancel := context.WithCancel(context.Background()) cancel() + <-canceledCtx.Done() // Ensure the close of the Done channel sender1, err := ec.TransactionSender(canceledCtx, tx1, block2.Hash(), 0) if err != nil { t.Fatal(err)