mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
test: Introduce MockableSteadyClock::mock_time_point and ElapseSteady helper
This refactor clarifies that the MockableSteadyClock::mock_time_point has millisecond precision by defining a type an using it. Moreover, a ElapseSteady helper is added which can be re-used easily.
This commit is contained in:
@@ -21,7 +21,7 @@ void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread
|
||||
|
||||
static std::atomic<std::chrono::seconds> g_mock_time{}; //!< For testing
|
||||
std::atomic<bool> g_used_system_time{false};
|
||||
static std::atomic<std::chrono::milliseconds> g_mock_steady_time{}; //!< For testing
|
||||
static std::atomic<MockableSteadyClock::mock_time_point::duration> g_mock_steady_time{}; //!< For testing
|
||||
|
||||
NodeClock::time_point NodeClock::now() noexcept
|
||||
{
|
||||
@@ -62,7 +62,7 @@ MockableSteadyClock::time_point MockableSteadyClock::now() noexcept
|
||||
return time_point{ret};
|
||||
};
|
||||
|
||||
void MockableSteadyClock::SetMockTime(std::chrono::milliseconds mock_time_in)
|
||||
void MockableSteadyClock::SetMockTime(mock_time_point::duration mock_time_in)
|
||||
{
|
||||
Assert(mock_time_in >= 0s);
|
||||
g_mock_steady_time.store(mock_time_in, std::memory_order_relaxed);
|
||||
|
||||
Reference in New Issue
Block a user