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:
Arran Schlosberg 2024-11-28 12:53:44 +00:00
parent 2e75e74435
commit 5b4ac11371
No known key found for this signature in database
GPG Key ID: 5DD5567C12C5F312
1 changed files with 3 additions and 8 deletions

View File

@ -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)
}
}()
}