Skip to content

Commit 1f11d2d

Browse files
authored
ethclient: ensure the close of canceled context (#28349)
1 parent 1b1611b commit 1f11d2d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ethclient/ethclient_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ func testTransactionInBlockInterrupted(t *testing.T, client *rpc.Client) {
393393
// Test tx in block interrupted.
394394
ctx, cancel := context.WithCancel(context.Background())
395395
cancel()
396+
<-ctx.Done() // Ensure the close of the Done channel
396397
tx, err := ec.TransactionInBlock(ctx, block.Hash(), 0)
397398
if tx != nil {
398399
t.Fatal("transaction should be nil")
@@ -666,6 +667,7 @@ func testTransactionSender(t *testing.T, client *rpc.Client) {
666667
// TransactionSender. Ensure the server is not asked by canceling the context here.
667668
canceledCtx, cancel := context.WithCancel(context.Background())
668669
cancel()
670+
<-canceledCtx.Done() // Ensure the close of the Done channel
669671
sender1, err := ec.TransactionSender(canceledCtx, tx1, block2.Hash(), 0)
670672
if err != nil {
671673
t.Fatal(err)

0 commit comments

Comments
 (0)