From a7498cc7e26b4b3de976e111de2bd2d79b056b31 Mon Sep 17 00:00:00 2001 From: marcofleon Date: Thu, 26 Sep 2024 12:02:34 +0100 Subject: [PATCH] Fix bug in p2p_headers_presync harness --- src/test/fuzz/p2p_headers_presync.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/fuzz/p2p_headers_presync.cpp b/src/test/fuzz/p2p_headers_presync.cpp index e22087303a..2670aa8ee4 100644 --- a/src/test/fuzz/p2p_headers_presync.cpp +++ b/src/test/fuzz/p2p_headers_presync.cpp @@ -197,16 +197,16 @@ FUZZ_TARGET(p2p_headers_presync, .init = initialize) auto headers_msg = NetMsg::Make(NetMsgType::BLOCK, TX_WITH_WITNESS(block)); g_testing_setup->SendMessage(fuzzed_data_provider, std::move(headers_msg)); }); - - // This is a conservative overestimate, as base is only moved forward when sending headers. In theory, - // the longest chain generated by this test is 1600 (FUZZ_MAX_HEADERS_RESULTS * 100) headers. In that case, - // this variable will accurately reflect the chain's total work. - total_work += CalculateClaimedHeadersWork(all_headers); - - // This test should never create a chain with more work than MinimumChainWork. - assert(total_work < chainman.MinimumChainWork()); } + // This is a conservative overestimate, as base is only moved forward when sending headers. In theory, + // the longest chain generated by this test is 1600 (FUZZ_MAX_HEADERS_RESULTS * 100) headers. In that case, + // this variable will accurately reflect the chain's total work. + total_work += CalculateClaimedHeadersWork(all_headers); + + // This test should never create a chain with more work than MinimumChainWork. + assert(total_work < chainman.MinimumChainWork()); + // The headers/blocks sent in this test should never be stored, as the chains don't have the work required // to meet the anti-DoS work threshold. So, if at any point the block index grew in size, then there's a bug // in the headers pre-sync logic.