From 47a7a1687d276bfa8769dee4bb78e8725f67a50e Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Fri, 12 Feb 2021 10:23:45 -0800 Subject: [util] Introduce a SetMockTime that takes chrono time --- src/util/time.cpp | 5 +++++ src/util/time.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/util/time.cpp b/src/util/time.cpp index 2589ec12a0..7b0eb8fd8e 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -53,6 +53,11 @@ void SetMockTime(int64_t nMockTimeIn) nMockTime.store(nMockTimeIn, std::memory_order_relaxed); } +void SetMockTime(std::chrono::seconds mock_time_in) +{ + nMockTime.store(mock_time_in.count(), std::memory_order_relaxed); +} + std::chrono::seconds GetMockTime() { return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed)); diff --git a/src/util/time.h b/src/util/time.h index 38edc71de1..52679a2647 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -46,6 +46,9 @@ int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable /** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */ void SetMockTime(int64_t nMockTimeIn); +/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */ +void SetMockTime(std::chrono::seconds mock_time_in); + /** For testing */ std::chrono::seconds GetMockTime(); -- cgit v1.2.3