From dd12bf58f3b37dcd0ff0d70f00de3d7b3b7edabe Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Mon, 20 Apr 2026 16:55:54 +0800 Subject: [PATCH] fix(eth/downloader): fix flaky test TestFakedSyncProgress64Full Make the mocked attacker remove the missing tail headers inclusively so the advertised height reduction matches the test expectation. --- eth/downloader/downloader_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index c2ca9171517b..b267350701f4 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -1454,7 +1454,11 @@ func testFakedSyncProgress(t *testing.T, protocol int, mode SyncMode) { // Create and sync with an attacker that promises a higher chain than available. brokenChain := chain.shorten(chain.len()) numMissing := 5 - for i := brokenChain.len() - 2; i > brokenChain.len()-numMissing; i-- { + // Remove the advertised tail inclusively so the attacker is short by exactly + // numMissing heights. The valid peer below is shortened by the same amount, + // so both the reduced HighestBlock and the final CurrentBlock must converge + // to chain.len()-numMissing-1. + for i := brokenChain.len() - 2; i >= brokenChain.len()-numMissing; i-- { delete(brokenChain.headerm, brokenChain.chain[i]) } tester.newPeer("attack", protocol, brokenChain)