diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-02-01 14:57:34 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2021-02-02 08:43:19 +0000 |
commit | 3ddbf22ed179a2db733af4b521bec5d2b13ebf4b (patch) | |
tree | 32d4bd53eec1c735bd1952312e527c578fa8623b /src/util | |
parent | f5f2f9716885e7548809e77f46b493c896a019bf (diff) | |
download | bitcoin-3ddbf22ed179a2db733af4b521bec5d2b13ebf4b.tar.xz |
util: Disallow negative mocktime
Signed-off-by: practicalswift <practicalswift@users.noreply.github.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/time.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/util/time.cpp b/src/util/time.cpp index e96972fe12..d130e4e4d4 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -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); } |