Skip to content

Commit fafaca6

Browse files
author
MarcoFalke
committed
fuzz: Avoid setting the mock-time twice
It should be sufficient to set it once. Especially, if the dynamic value is only used by ResetAndInitialize. This also avoids non-determistic code paths, when ResetAndInitialize may re-initialize m_next_inv_to_inbounds. Without this patch, the tool would report a diff: cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32 ... - 1126| 3| m_next_inv_to_inbounds = now + m_rng.rand_exp_duration(average_interval); - 1127| 3| } + 1126| 10| m_next_inv_to_inbounds = now + m_rng.rand_exp_duration(average_interval); + 1127| 10| } 1128| 491| return m_next_inv_to_inbounds; ...
1 parent fad2214 commit fafaca6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/test/fuzz/p2p_headers_presync.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,15 @@ FUZZ_TARGET(p2p_headers_presync, .init = initialize)
162162
// The steady clock is currently only used for logging, so a constant
163163
// time-point seems acceptable for now.
164164
ElapseSteady elapse_steady{};
165-
SetMockTime(ConsumeTime(fuzzed_data_provider));
166165

167166
ChainstateManager& chainman = *g_testing_setup->m_node.chainman;
167+
CBlockHeader base{chainman.GetParams().GenesisBlock()};
168+
SetMockTime(base.nTime);
168169

169170
LOCK(NetEventsInterface::g_msgproc_mutex);
170171

171172
g_testing_setup->ResetAndInitialize();
172173

173-
CBlockHeader base{chainman.GetParams().GenesisBlock()};
174-
SetMockTime(base.nTime);
175-
176174
// The chain is just a single block, so this is equal to 1
177175
size_t original_index_size{WITH_LOCK(cs_main, return chainman.m_blockman.m_block_index.size())};
178176
arith_uint256 total_work{WITH_LOCK(cs_main, return chainman.m_best_header->nChainWork)};

0 commit comments

Comments
 (0)