diff --git a/src/logging.cpp b/src/logging.cpp index 4ddcf1d930..529bb11d5b 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -203,9 +203,9 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str) strStamped.pop_back(); strStamped += strprintf(".%06dZ", nTimeMicros%1000000); } - int64_t mocktime = GetMockTime(); - if (mocktime) { - strStamped += " (mocktime: " + FormatISO8601DateTime(mocktime) + ")"; + std::chrono::seconds mocktime = GetMockTime(); + if (mocktime > 0s) { + strStamped += " (mocktime: " + FormatISO8601DateTime(count_seconds(mocktime)) + ")"; } strStamped += ' ' + str; } else diff --git a/src/util/time.cpp b/src/util/time.cpp index 295806c54a..2589ec12a0 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -53,9 +53,9 @@ void SetMockTime(int64_t nMockTimeIn) nMockTime.store(nMockTimeIn, std::memory_order_relaxed); } -int64_t GetMockTime() +std::chrono::seconds GetMockTime() { - return nMockTime.load(std::memory_order_relaxed); + return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed)); } int64_t GetTimeMillis() diff --git a/src/util/time.h b/src/util/time.h index 03b75b5be5..38edc71de1 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -45,8 +45,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 */ -int64_t GetMockTime(); +std::chrono::seconds GetMockTime(); /** Return system time (or mocked time, if set) */ template