Mercurial > hg > bitcoin
comparison src/util.cpp @ 1299:432633b3e50d draft
SetMockTime() for cleaner unit testing
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Thu, 15 Sep 2011 08:55:15 -0400 |
parents | b0a8d376ead4 |
children | 17e35c4c73f7 |
comparison
equal
deleted
inserted
replaced
1298:cc019959db9c | 1299:432633b3e50d |
---|---|
813 // Our three time sources are: | 813 // Our three time sources are: |
814 // - System clock | 814 // - System clock |
815 // - Median of other nodes's clocks | 815 // - Median of other nodes's clocks |
816 // - The user (asking the user to fix the system clock if the first two disagree) | 816 // - The user (asking the user to fix the system clock if the first two disagree) |
817 // | 817 // |
818 static int64 nMockTime = 0; // For unit testing | |
819 | |
818 int64 GetTime() | 820 int64 GetTime() |
819 { | 821 { |
822 if (nMockTime) return nMockTime; | |
823 | |
820 return time(NULL); | 824 return time(NULL); |
825 } | |
826 | |
827 void SetMockTime(int64 nMockTimeIn) | |
828 { | |
829 nMockTime = nMockTimeIn; | |
821 } | 830 } |
822 | 831 |
823 static int64 nTimeOffset = 0; | 832 static int64 nTimeOffset = 0; |
824 | 833 |
825 int64 GetAdjustedTime() | 834 int64 GetAdjustedTime() |