diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 5a1b6b94c6..0fc46e1310 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -456,8 +456,8 @@ func testCanonSync(t *testing.T, protocol uint, mode SyncMode, snapV2 bool) { select { case <-success: assertOwnChain(t, tester, len(chain.blocks)) - case <-time.NewTimer(time.Second * 3).C: - t.Fatalf("Failed to sync chain in three seconds") + case <-time.NewTimer(time.Second * 30).C: + t.Fatalf("Failed to sync chain in time") } } @@ -605,8 +605,8 @@ func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) { HighestBlock: uint64(len(chain.blocks) - 1), CurrentBlock: uint64(len(chain.blocks) - 1), }) - case <-time.NewTimer(time.Second * 3).C: - t.Fatalf("Failed to sync chain in three seconds") + case <-time.NewTimer(time.Second * 30).C: + t.Fatalf("Failed to sync chain in time") } assertOwnChain(t, tester, len(chain.blocks)) @@ -679,8 +679,8 @@ func testBeaconSync(t *testing.T, protocol uint, mode SyncMode) { if bs := int(tester.chain.CurrentBlock().Number.Uint64()) + 1; bs != len(chain.blocks) { t.Fatalf("synchronised blocks mismatch: have %v, want %v", bs, len(chain.blocks)) } - case <-time.NewTimer(time.Second * 3).C: - t.Fatalf("Failed to sync chain in three seconds") + case <-time.NewTimer(time.Second * 30).C: + t.Fatalf("Failed to sync chain in time") } }) } @@ -790,8 +790,8 @@ func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) { CurrentBlock: uint64(len(chain.blocks)/2 - 1), HighestBlock: uint64(len(chain.blocks)/2 - 1), }) - case <-time.NewTimer(time.Second * 3).C: - t.Fatalf("Failed to sync chain in three seconds") + case <-time.NewTimer(time.Second * 30).C: + t.Fatalf("Failed to sync chain in time") } // Synchronise all the blocks and check continuation progress @@ -809,8 +809,8 @@ func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) { CurrentBlock: uint64(len(chain.blocks) - 1), HighestBlock: uint64(len(chain.blocks) - 1), }) - case <-time.NewTimer(time.Second * 3).C: - t.Fatalf("Failed to sync chain in three seconds") + case <-time.NewTimer(time.Second * 30).C: + t.Fatalf("Failed to sync chain in time") } } diff --git a/eth/downloader/skeleton_test.go b/eth/downloader/skeleton_test.go index 9962d4f1a3..7b66a415a9 100644 --- a/eth/downloader/skeleton_test.go +++ b/eth/downloader/skeleton_test.go @@ -922,7 +922,14 @@ func TestSkeletonSyncRetrievals(t *testing.T) { endpeers = append(tt.peers, tt.newPeer) } if tt.newHead != nil { - skeleton.Sync(tt.newHead, nil, true) + // The head announcement is rejected if it arrives while the previous + // sync cycle is still tearing down (head events are dropped on the + // floor during teardown, see #27397). Retry until the syncer accepts + // the new head, otherwise the update is lost and the end state below + // is never reached. + for skeleton.Sync(tt.newHead, nil, true) != nil { + time.Sleep(10 * time.Millisecond) + } } // Wait a bit (bleah) for the second sync loop to go to idle. This might