mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
fuzz: share a single mocked steady clock across FuzzedSock instances
Each FuzzedSock used to own its mocked steady clock and call MockableSteadyClock::SetMockTime() directly. Hold the clock by reference to an externally provided FakeSteadyClock instead, so that several FuzzedSock instances sharing a test case (e.g. one per peer, or one created via Accept()) advance a single mocked clock, and the mocking goes through the FakeSteadyClock RAII helper that resets mocktime on destruction. FakeSteadyClock is a LimitOne type, so each fuzz target constructs one instance per iteration and passes it to ConsumeSock / ConsumeNode / the FuzzedSock constructor.
This commit is contained in:
@@ -84,6 +84,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
|
||||
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
|
||||
FakeNodeClock clock{1610000000s}; // any time to successfully reset ibd
|
||||
FakeSteadyClock steady_clock;
|
||||
chainman.ResetIbd();
|
||||
chainman.DisableNextWrite();
|
||||
|
||||
@@ -111,7 +112,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
||||
|
||||
node.validation_signals->RegisterValidationInterface(node.peerman.get());
|
||||
|
||||
CNode& p2p_node = *ConsumeNodeAsUniquePtr(fuzzed_data_provider).release();
|
||||
CNode& p2p_node = *ConsumeNodeAsUniquePtr(fuzzed_data_provider, steady_clock).release();
|
||||
|
||||
connman.AddTestNode(p2p_node);
|
||||
FillNode(fuzzed_data_provider, connman, p2p_node);
|
||||
|
||||
Reference in New Issue
Block a user