aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2011-09-15 08:55:15 -0400
committerGavin Andresen <[email protected]>2011-09-21 12:01:56 -0400
commit54d02f158d79b078ed9afdca5e37241101b040cd (patch)
tree1c1afb1dae4adfb6730b59199b325ecde7b46987 /src/util.cpp
parentMerge pull request #522 from sipa/minorfix (diff)
downloaddiscoin-54d02f158d79b078ed9afdca5e37241101b040cd.tar.xz
discoin-54d02f158d79b078ed9afdca5e37241101b040cd.zip
SetMockTime() for cleaner unit testing
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp9
1 files changed, 9 insertions, 0 deletions
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()