From 855a3fee8829447ca580d01fb96bff8d4eaf30db Mon Sep 17 00:00:00 2001 From: Hao Xu Date: Thu, 18 Jun 2026 15:04:24 +0800 Subject: [PATCH] scripted-diff: Rename SteadyClockContext to FakeSteadyClock SteadyClockContext and FakeNodeClock are both LimitOne RAII helpers that mock a clock in tests -- the steady clock and the node clock, respectively. Rename the former so the two follow a consistent FakeXClock naming scheme. -BEGIN VERIFY SCRIPT- sed -i 's/SteadyClockContext/FakeSteadyClock/g' $(git grep -l SteadyClockContext) -END VERIFY SCRIPT- --- src/test/fuzz/p2p_headers_presync.cpp | 2 +- src/test/fuzz/util/check_globals.cpp | 2 +- src/test/pcp_tests.cpp | 2 +- src/test/util/time.h | 10 +++++----- src/util/time.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/fuzz/p2p_headers_presync.cpp b/src/test/fuzz/p2p_headers_presync.cpp index d8a748ee6ea..fa041f34fe4 100644 --- a/src/test/fuzz/p2p_headers_presync.cpp +++ b/src/test/fuzz/p2p_headers_presync.cpp @@ -164,7 +164,7 @@ FUZZ_TARGET(p2p_headers_presync, .init = initialize) FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; // The steady clock is currently only used for logging, so a constant // time-point seems acceptable for now. - SteadyClockContext steady_ctx{}; + FakeSteadyClock steady_ctx{}; ChainstateManager& chainman = *g_testing_setup->m_node.chainman; CBlockHeader base{chainman.GetParams().GenesisBlock()}; diff --git a/src/test/fuzz/util/check_globals.cpp b/src/test/fuzz/util/check_globals.cpp index 1c29906932c..431519dc269 100644 --- a/src/test/fuzz/util/check_globals.cpp +++ b/src/test/fuzz/util/check_globals.cpp @@ -44,7 +44,7 @@ struct CheckGlobalsImpl { "The current fuzz target accessed system time.\n\n" "This is acceptable, but requires the fuzz target to use \n" - "a FakeNodeClock, SteadyClockContext or call \n" + "a FakeNodeClock, FakeSteadyClock or call \n" "SetMockTime() at the \n" "beginning of processing the \n" "fuzz input.\n\n" diff --git a/src/test/pcp_tests.cpp b/src/test/pcp_tests.cpp index 8ecbab58d25..9f69e63e2cf 100644 --- a/src/test/pcp_tests.cpp +++ b/src/test/pcp_tests.cpp @@ -222,7 +222,7 @@ private: const std::vector m_script; mutable size_t m_script_ptr = 0; mutable std::chrono::milliseconds m_time_left; - mutable SteadyClockContext m_clock{}; + mutable FakeSteadyClock m_clock{}; mutable bool m_connected{false}; mutable CService m_bound; mutable CNetAddr m_local_ip; diff --git a/src/test/util/time.h b/src/test/util/time.h index 2bc2553fea2..213d7b2764c 100644 --- a/src/test/util/time.h +++ b/src/test/util/time.h @@ -25,19 +25,19 @@ private: /// Helper to initialize the global MockableSteadyClock, let a duration elapse, /// and reset it after use in a test. -class SteadyClockContext : public LimitOne +class FakeSteadyClock : public LimitOne { MockableSteadyClock::mock_time_point::duration t{MockableSteadyClock::INITIAL_MOCK_TIME}; public: /** Initialize with INITIAL_MOCK_TIME. */ - explicit SteadyClockContext() { (*this) += 0s; } + explicit FakeSteadyClock() { (*this) += 0s; } /** Unset mocktime */ - ~SteadyClockContext() { MockableSteadyClock::ClearMockTime(); } + ~FakeSteadyClock() { MockableSteadyClock::ClearMockTime(); } - SteadyClockContext(const SteadyClockContext&) = delete; - SteadyClockContext& operator=(const SteadyClockContext&) = delete; + FakeSteadyClock(const FakeSteadyClock&) = delete; + FakeSteadyClock& operator=(const FakeSteadyClock&) = delete; /** Change mocktime by the given duration delta */ void operator+=(std::chrono::milliseconds d) diff --git a/src/util/time.h b/src/util/time.h index 2e54ff85a70..7df7c39a355 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -42,7 +42,7 @@ using SteadyMicroseconds = std::chrono::time_point;