Merge pull request #10461 from filecoin-project/steb/deflake-fail-after-finish

fix: itest: avoid failing the test when we race the miner
This commit is contained in:
Aayush Rajasekaran 2023-03-13 15:13:08 -04:00 committed by GitHub
commit 97a9921cdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,12 +192,15 @@ func (bm *BlockMiner) MineBlocksMustPost(ctx context.Context, blocktime time.Dur
reportSuccessFn := func(success bool, epoch abi.ChainEpoch, err error) { 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 // 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) // (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) require.NoError(bm.t, err)
} }
target = epoch target = epoch
wait <- success select {
case wait <- success:
case <-ctx.Done():
}
} }
var success bool var success bool