Skip to content

Commit 64f705a

Browse files
committed
Extended the wait logic
1 parent 0e45065 commit 64f705a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

eth/sync_test.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,23 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) {
8888
if err := empty.handler.downloader.BeaconSync(ethconfig.SnapSync, full.chain.CurrentBlock(), nil); err != nil {
8989
t.Fatal("sync failed:", err)
9090
}
91-
// Downloader internally has to wait for a timer (3s) to be expired before
92-
// exiting. Poll after to determine if sync is disabled.
93-
time.Sleep(time.Second * 3)
94-
for timeout := time.After(time.Second); ; {
91+
// Instead of relying on a fixed sleep, poll for the flag within a generous deadline
92+
// to accommodate slow CI runners
93+
checkTicker := time.NewTicker(100 * time.Millisecond)
94+
defer checkTicker.Stop()
95+
96+
checkDeadline := time.NewTimer(6 * time.Second)
97+
defer checkDeadline.Stop()
98+
99+
for {
100+
if !empty.handler.snapSync.Load() {
101+
return
102+
}
95103
select {
96-
case <-timeout:
104+
case <-checkTicker.C:
105+
continue
106+
case <-checkDeadline.C:
97107
t.Fatalf("snap sync not disabled after successful synchronisation")
98-
case <-time.After(100 * time.Millisecond):
99-
if !empty.handler.snapSync.Load() {
100-
return
101-
}
102108
}
103109
}
104110
}

0 commit comments

Comments
 (0)