From b852f5e2fd9e690622023b9288a4327805f7964c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Mar 2023 11:14:38 -0700 Subject: [PATCH] fix: itest: avoid failing the test when we race the miner I've been seeing quite a few tests failing here, so I'm hoping this will deflake them a bit. --- itests/kit/blockminer.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/itests/kit/blockminer.go b/itests/kit/blockminer.go index 9dd83ee470..4cd0cc671c 100644 --- a/itests/kit/blockminer.go +++ b/itests/kit/blockminer.go @@ -192,12 +192,15 @@ func (bm *BlockMiner) MineBlocksMustPost(ctx context.Context, blocktime time.Dur reportSuccessFn := func(success bool, epoch abi.ChainEpoch, err error) { // if api shuts down before mining, we may get an error which we should probably just ignore // (fixing it will require rewriting most of the mining loop) - if err != nil && !strings.Contains(err.Error(), "websocket connection closed") && !api.ErrorIsIn(err, []error{new(jsonrpc.RPCConnectionError)}) { + if err != nil && ctx.Err() == nil && !strings.Contains(err.Error(), "websocket connection closed") && !api.ErrorIsIn(err, []error{new(jsonrpc.RPCConnectionError)}) { require.NoError(bm.t, err) } target = epoch - wait <- success + select { + case wait <- success: + case <-ctx.Done(): + } } var success bool