mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
util: Disallow negative mocktime
Signed-off-by: practicalswift <practicalswift@users.noreply.github.com>
This commit is contained in:
committed by
practicalswift
parent
f5f2f97168
commit
3ddbf22ed1
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <util/time.h>
|
||||
|
||||
#include <util/check.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <ctime>
|
||||
@@ -18,7 +20,7 @@
|
||||
|
||||
void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); }
|
||||
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For unit testing
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For testing
|
||||
|
||||
int64_t GetTime()
|
||||
{
|
||||
@@ -46,6 +48,7 @@ template std::chrono::microseconds GetTime();
|
||||
|
||||
void SetMockTime(int64_t nMockTimeIn)
|
||||
{
|
||||
Assert(nMockTimeIn >= 0);
|
||||
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user