From 4453181741853b3bda7801e82f4a67659c7e81e7 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Wed, 15 Jun 2022 17:16:17 +0000 Subject: [PATCH] fix(dot/sync): fix `Test_lockQueue_threadSafety` --- dot/sync/block_queue_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dot/sync/block_queue_test.go b/dot/sync/block_queue_test.go index f6796083bb..1691cf46e9 100644 --- a/dot/sync/block_queue_test.go +++ b/dot/sync/block_queue_test.go @@ -219,6 +219,17 @@ func Test_lockQueue_threadSafety(t *testing.T) { } blockHash := common.Hash{1} + endWg.Add(1) + go func() { + defer endWg.Done() + <-ctx.Done() + // Empty queue channel to make sure `push` does not block + // when the context is cancelled. + for len(blockQueue.queue) > 0 { + <-blockQueue.queue + } + }() + for i := 0; i < parallelism; i++ { go runInLoop(func() { blockQueue.push(blockData)