diff --git a/orderer/common/cluster/deliver_test.go b/orderer/common/cluster/deliver_test.go index 6c63bc29a43..990422938c7 100644 --- a/orderer/common/cluster/deliver_test.go +++ b/orderer/common/cluster/deliver_test.go @@ -1086,7 +1086,11 @@ func TestBlockPullerBadBlocks(t *testing.T) { return nil })) - bp.PullBlock(10) + endPullBlock := make(chan struct{}) + go func() { + bp.PullBlock(10) + close(endPullBlock) + }() select { case <-detectedBadBlockDone: @@ -1094,6 +1098,14 @@ func TestBlockPullerBadBlocks(t *testing.T) { t.Fatalf("expected %q to be logged but it was not seen", testCase.expectedErrMsg) } + select { + case <-endPullBlock: + case <-time.After(10 * time.Second): + // Signal PullBlock to give up on the retries & mark the test as fail + close(bp.StopChannel) + t.Fatalf("PullBlock did not complete within time") + } + bp.Close() dialer.assertAllConnectionsClosed(t) })