Skip to content
Browse files
Merge pull request #6337
6a4b97e Testing infrastructure: mocktime fixes (Gavin Andresen)
  • Loading branch information
laanwj committed Jun 29, 2015
2 parents 24f2489 + 6a4b97e commit 0564c5b795d1be675a0ac0a2e8038db0970ac376
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
@@ -868,6 +868,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)

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

// Initialize elliptic curve code
@@ -378,10 +378,19 @@ UniValue setmocktime(const UniValue& params, bool fHelp)
if (!Params().MineBlocksOnDemand())
throw runtime_error("setmocktime for regression testing (-regtest mode) only");

// 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));

uint64_t t = GetTime();
BOOST_FOREACH(CNode* pnode, vNodes) {
pnode->nLastSend = pnode->nLastRecv = t;

return NullUniValue;

0 comments on commit 0564c5b

Please sign in to comment.