Skip to content

Commit

Permalink
fix: remove race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Jan 30, 2023
1 parent 5f5752d commit b8ae899
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libs/header/sync/ranges_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sync

import (
"sync"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -13,12 +14,17 @@ func TestAddParallel(t *testing.T) {

n := 500
suite := test.NewTestSuite(t)
headers := suite.GenDummyHeaders(1000)
headers := suite.GenDummyHeaders(n)

wg := &sync.WaitGroup{}
wg.Add(n)
for i := 0; i < n; i++ {
go func(i int) {
pending.Add(headers[i])
wg.Done()
}(i)
}
wg.Wait()

last := uint64(0)
for _, r := range pending.ranges {
Expand Down

0 comments on commit b8ae899

Please sign in to comment.