mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge pull request #6337
6a4b97e
Testing infrastructure: mocktime fixes (Gavin Andresen)
This commit is contained in:
commit
0564c5b795
@ -868,6 +868,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
|
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
|
||||||
|
|
||||||
|
// Option to startup with mocktime set (used for regression testing):
|
||||||
|
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
|
||||||
|
|
||||||
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
||||||
|
|
||||||
// Initialize elliptic curve code
|
// Initialize elliptic curve code
|
||||||
|
@ -378,10 +378,19 @@ UniValue setmocktime(const UniValue& params, bool fHelp)
|
|||||||
if (!Params().MineBlocksOnDemand())
|
if (!Params().MineBlocksOnDemand())
|
||||||
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
|
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
|
||||||
|
|
||||||
LOCK(cs_main);
|
// cs_vNodes is locked and node send/receive times are updated
|
||||||
|
// atomically with the time change to prevent peers from being
|
||||||
|
// disconnected because we think we haven't communicated with them
|
||||||
|
// in a long time.
|
||||||
|
LOCK2(cs_main, cs_vNodes);
|
||||||
|
|
||||||
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
|
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
|
||||||
SetMockTime(params[0].get_int64());
|
SetMockTime(params[0].get_int64());
|
||||||
|
|
||||||
|
uint64_t t = GetTime();
|
||||||
|
BOOST_FOREACH(CNode* pnode, vNodes) {
|
||||||
|
pnode->nLastSend = pnode->nLastRecv = t;
|
||||||
|
}
|
||||||
|
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user