test: block on `terminate(false)` instead of `wait()`
This is effectively the same thing as both wait on `<-sf.term` but it makes for a clearer test that demonstrates the bug because `terminate(false)` is documented as blocking until "all disk loads finish".
This commit is contained in:
parent
2e75e74435
commit
5b4ac11371
|
@ -83,7 +83,7 @@ func TestSchdeulerTerminationRaceCondition(t *testing.T) {
|
|||
var wg sync.WaitGroup
|
||||
|
||||
for i := 0; i < 50_000; i++ {
|
||||
wg.Add(3)
|
||||
wg.Add(2)
|
||||
fetcher := newSubfetcher(db.db, db.originalRoot, common.Hash{}, db.originalRoot, common.Address{})
|
||||
|
||||
var gotScheduleErr error
|
||||
|
@ -98,16 +98,11 @@ func TestSchdeulerTerminationRaceCondition(t *testing.T) {
|
|||
go func() {
|
||||
defer wg.Done()
|
||||
<-start
|
||||
fetcher.terminate(false)
|
||||
}()
|
||||
fetcher.terminate(false /*async*/)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
<-doneScheduling
|
||||
fetcher.wait()
|
||||
|
||||
if gotScheduleErr == nil && len(fetcher.tasks) > 0 {
|
||||
t.Errorf("%T.schedule() returned nil error but %d task(s) remain in queue after %T.wait() returned", fetcher, len(fetcher.tasks), fetcher)
|
||||
t.Errorf("%T.schedule() returned nil error but %d task(s) remain in queue after %T.terminate([blocking]) returned", fetcher, len(fetcher.tasks), fetcher)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue