diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2014-11-18 14:29:38 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2014-11-18 14:31:29 -0500 |
commit | fd3777b0b272ad4ce7fbb152917353aa46879f89 (patch) | |
tree | 2c5a27dbd19273204fb4544f3807813863f8cc87 /src | |
parent | e3560029ceb7899b6c8a9d59d803de7190ff65bd (diff) | |
parent | 3c30f27f342c15af17c6f7e160be5ee60f28194d (diff) |
Merge pull request #5280
3c30f27 travis: disable rpc tests for windows until they're not so flaky (Cory Fields)
daf03e7 RPC tests: create initial chain with specific timestamps (Gavin Andresen)
a8b2ce5 regression test only setmocktime RPC call (Gavin Andresen)
Diffstat (limited to 'src')
-rw-r--r-- | src/rpcclient.cpp | 1 | ||||
-rw-r--r-- | src/rpcmisc.cpp | 20 | ||||
-rw-r--r-- | src/rpcserver.cpp | 1 | ||||
-rw-r--r-- | src/rpcserver.h | 1 |
4 files changed, 23 insertions, 0 deletions
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index a9c491cede..7a1f1918f6 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -25,6 +25,7 @@ public: static const CRPCConvertParam vRPCConvertParams[] = { { "stop", 0 }, + { "setmocktime", 0 }, { "getaddednodeinfo", 0 }, { "setgenerate", 0 }, { "setgenerate", 1 }, diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 08e956c961..31eaae6162 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -354,3 +354,23 @@ Value verifymessage(const Array& params, bool fHelp) return (pubkey.GetID() == keyID); } + +Value setmocktime(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "setmocktime timestamp\n" + "\nSet the local time to given timestamp (-regtest only)\n" + "\nArguments:\n" + "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" + " Pass 0 to go back to using the system time." + ); + + if (!Params().MineBlocksOnDemand()) + throw runtime_error("setmocktime for regression testing (-regtest mode) only"); + + RPCTypeCheck(params, boost::assign::list_of(int_type)); + SetMockTime(params[0].get_int64()); + + return Value::null; +} diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 8b042e6003..01005c1cee 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -246,6 +246,7 @@ static const CRPCCommand vRPCCommands[] = { "control", "getinfo", &getinfo, true, false, false }, /* uses wallet if enabled */ { "control", "help", &help, true, true, false }, { "control", "stop", &stop, true, true, false }, + { "control", "setmocktime", &setmocktime, true, false, false }, /* P2P networking */ { "network", "getnetworkinfo", &getnetworkinfo, true, false, false }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 60793f79ae..b3234f65f2 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -194,6 +194,7 @@ extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblockchaininfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value setmocktime(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp); |