mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
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
1 changed files with 3 additions and 8 deletions
|
|
@ -83,7 +83,7 @@ func TestSchdeulerTerminationRaceCondition(t *testing.T) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
for i := 0; i < 50_000; i++ {
|
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{})
|
fetcher := newSubfetcher(db.db, db.originalRoot, common.Hash{}, db.originalRoot, common.Address{})
|
||||||
|
|
||||||
var gotScheduleErr error
|
var gotScheduleErr error
|
||||||
|
|
@ -98,16 +98,11 @@ func TestSchdeulerTerminationRaceCondition(t *testing.T) {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
<-start
|
<-start
|
||||||
fetcher.terminate(false)
|
fetcher.terminate(false /*async*/)
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
<-doneScheduling
|
<-doneScheduling
|
||||||
fetcher.wait()
|
|
||||||
|
|
||||||
if gotScheduleErr == nil && len(fetcher.tasks) > 0 {
|
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 a new issue