Skip to content

Commit 223cfbb

Browse files
authored
fix(dot/sync): fix Test_lockQueue_threadSafety (#2605)
1 parent 6a9d85b commit 223cfbb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dot/sync/block_queue_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ func Test_lockQueue_threadSafety(t *testing.T) {
219219
}
220220
blockHash := common.Hash{1}
221221

222+
endWg.Add(1)
223+
go func() {
224+
defer endWg.Done()
225+
<-ctx.Done()
226+
// Empty queue channel to make sure `push` does not block
227+
// when the context is cancelled.
228+
for len(blockQueue.queue) > 0 {
229+
<-blockQueue.queue
230+
}
231+
}()
232+
222233
for i := 0; i < parallelism; i++ {
223234
go runInLoop(func() {
224235
blockQueue.push(blockData)

0 commit comments

Comments
 (0)