Skip to content

Commit

Permalink
fix(dot/sync): fix Test_lockQueue_threadSafety
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 15, 2022
1 parent 7f55bec commit 4453181
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dot/sync/block_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4453181

Please sign in to comment.