From 54d02f158d79b078ed9afdca5e37241101b040cd Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 15 Sep 2011 08:55:15 -0400 Subject: SetMockTime() for cleaner unit testing --- src/util.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 76a270027..14ca87b62 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -815,11 +815,20 @@ void ShrinkDebugFile() // - Median of other nodes's clocks // - The user (asking the user to fix the system clock if the first two disagree) // +static int64 nMockTime = 0; // For unit testing + int64 GetTime() { + if (nMockTime) return nMockTime; + return time(NULL); } +void SetMockTime(int64 nMockTimeIn) +{ + nMockTime = nMockTimeIn; +} + static int64 nTimeOffset = 0; int64 GetAdjustedTime() -- cgit v1.2.3