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:
Hao Xu
2026-06-15 19:35:25 +08:00
parent 6b58eb6d51
commit 6fa4132298
11 changed files with 45 additions and 40 deletions

View File

@@ -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);