MCPcopy Create free account
hub / github.com/ElementsProject/elements / mockscheduler

Function mockscheduler

src/rpc/misc.cpp:501–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499#endif // USE_SYSCALL_SANDBOX
500
501static RPCHelpMan mockscheduler()
502{
503 return RPCHelpMan{"mockscheduler",
504 "\nBump the scheduler into the future (-regtest only)\n",
505 {
506 {"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, "Number of seconds to forward the scheduler into the future." },
507 },
508 RPCResult{RPCResult::Type::NONE, "", ""},
509 RPCExamples{""},
510 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
511{
512 if (!Params().IsMockableChain()) {
513 throw std::runtime_error("mockscheduler is for regression testing (-regtest mode) only");
514 }
515
516 // check params are valid values
517 RPCTypeCheck(request.params, {UniValue::VNUM});
518 int64_t delta_seconds = request.params[0].get_int64();
519 if (delta_seconds <= 0 || delta_seconds > 3600) {
520 throw std::runtime_error("delta_time must be between 1 and 3600 seconds (1 hr)");
521 }
522
523 auto node_context = util::AnyPtr<NodeContext>(request.context);
524 // protect against null pointer dereference
525 CHECK_NONFATAL(node_context);
526 CHECK_NONFATAL(node_context->scheduler);
527 node_context->scheduler->MockForward(std::chrono::seconds(delta_seconds));
528
529 return NullUniValue;
530},
531 };
532}
533
534static UniValue RPCLockedMemoryInfo()
535{

Callers

nothing calls this directly

Calls 5

RPCTypeCheckFunction · 0.85
IsMockableChainMethod · 0.80
get_int64Method · 0.80
MockForwardMethod · 0.80
ParamsClass · 0.50

Tested by

no test coverage detected