mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
eth: fix the flaky test of TestSnapSyncDisabling68
Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
parent
406a852ec8
commit
54ddccf116
1 changed files with 10 additions and 7 deletions
|
|
@ -82,15 +82,18 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) {
|
||||||
if err := empty.handler.downloader.BeaconSync(full.chain.CurrentBlock(), nil); err != nil {
|
if err := empty.handler.downloader.BeaconSync(full.chain.CurrentBlock(), nil); err != nil {
|
||||||
t.Fatal("sync failed:", err)
|
t.Fatal("sync failed:", err)
|
||||||
}
|
}
|
||||||
// Downloader internally has to wait for a timer (3s) to be expired before
|
// Snap sync and mode switching happen asynchronously, poll for completion.
|
||||||
// exiting. Poll after to determine if sync is disabled.
|
timeout := time.NewTimer(15 * time.Second)
|
||||||
time.Sleep(time.Second * 3)
|
tick := time.NewTicker(100 * time.Millisecond)
|
||||||
for timeout := time.After(time.Second); ; {
|
defer timeout.Stop()
|
||||||
|
defer tick.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timeout:
|
case <-timeout.C:
|
||||||
t.Fatalf("snap sync not disabled after successful synchronisation")
|
t.Fatalf("snap sync not disabled after successful synchronisation")
|
||||||
case <-time.After(100 * time.Millisecond):
|
case <-tick.C:
|
||||||
if empty.handler.downloader.ConfigSyncMode() == ethconfig.FullSync {
|
if empty.handler.synced.Load() && empty.handler.downloader.ConfigSyncMode() == ethconfig.FullSync {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue