From 8574028a9716e8dfd890212e34ed9c4d1047197e Mon Sep 17 00:00:00 2001 From: lightclient Date: Tue, 26 Aug 2025 14:52:55 -0600 Subject: [PATCH] eth: use loop+select polling to speed up test --- eth/sync_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/eth/sync_test.go b/eth/sync_test.go index 359342b3fd..4e874a8b39 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -89,13 +89,14 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) { t.Fatal("sync failed:", err) } // Wait for downloader to finish processing with a timeout - for t0 := time.Now(); time.Since(t0) < 10*time.Second; time.Sleep(100 * time.Millisecond) { - if !empty.handler.snapSync.Load() { - break + for timeout := time.After(5 * time.Second); ; { + select { + case <-timeout: + t.Fatalf("snap sync not disabled after successful synchronisation") + case <-time.After(100 * time.Millisecond): + if !empty.handler.snapSync.Load() { + return + } } } - - if empty.handler.snapSync.Load() { - t.Fatalf("snap sync not disabled after successful synchronisation") - } }