mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
SetMockTime() for cleaner unit testing
This commit is contained in:
parent
700f942692
commit
54d02f158d
@ -815,11 +815,20 @@ void ShrinkDebugFile()
|
|||||||
// - Median of other nodes's clocks
|
// - Median of other nodes's clocks
|
||||||
// - The user (asking the user to fix the system clock if the first two disagree)
|
// - The user (asking the user to fix the system clock if the first two disagree)
|
||||||
//
|
//
|
||||||
|
static int64 nMockTime = 0; // For unit testing
|
||||||
|
|
||||||
int64 GetTime()
|
int64 GetTime()
|
||||||
{
|
{
|
||||||
|
if (nMockTime) return nMockTime;
|
||||||
|
|
||||||
return time(NULL);
|
return time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetMockTime(int64 nMockTimeIn)
|
||||||
|
{
|
||||||
|
nMockTime = nMockTimeIn;
|
||||||
|
}
|
||||||
|
|
||||||
static int64 nTimeOffset = 0;
|
static int64 nTimeOffset = 0;
|
||||||
|
|
||||||
int64 GetAdjustedTime()
|
int64 GetAdjustedTime()
|
||||||
|
@ -199,6 +199,7 @@ void ShrinkDebugFile();
|
|||||||
int GetRandInt(int nMax);
|
int GetRandInt(int nMax);
|
||||||
uint64 GetRand(uint64 nMax);
|
uint64 GetRand(uint64 nMax);
|
||||||
int64 GetTime();
|
int64 GetTime();
|
||||||
|
void SetMockTime(int64 nMockTimeIn);
|
||||||
int64 GetAdjustedTime();
|
int64 GetAdjustedTime();
|
||||||
void AddTimeData(unsigned int ip, int64 nTime);
|
void AddTimeData(unsigned int ip, int64 nTime);
|
||||||
std::string FormatFullVersion();
|
std::string FormatFullVersion();
|
||||||
|
Loading…
Reference in New Issue
Block a user