diff options
author | fanquake <fanquake@gmail.com> | 2023-07-30 11:18:27 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-07-30 11:21:40 +0100 |
commit | 64440bb733896a7a2caf902825e0406cb993e666 (patch) | |
tree | 847dd70f0410247a68fee206d1c48f2c16e32cf9 /src/rpc | |
parent | 4c57e53a61e6ae65ee87a25b1355530224b5ae9e (diff) | |
parent | fabef121b0cdfac6ec1985f6c08c5685a886ba5a (diff) |
Merge bitcoin/bitcoin#28118: test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC
fabef121b0cdfac6ec1985f6c08c5685a886ba5a refactor: Use EnsureAnyNodeContext (MarcoFalke)
fa1640617e061431059908fbf496dccca6b4e112 test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC (MarcoFalke)
Pull request description:
There should be no risk or downside in adding a call to `SyncWithValidationInterfaceQueue` here. In fact, it will make tests less brittle. For example,
* If one sets the timeouts in `test/functional/feature_fee_estimation.py` to `0`, on `master` the test will fail and here it will pass.
* It may avoid a rare (theoretic) intermittent issue in https://github.com/bitcoin/bitcoin/pull/28108/files#r1268966663
ACKs for top commit:
TheCharlatan:
ACK fabef121b0cdfac6ec1985f6c08c5685a886ba5a
furszy:
Code review ACK fabef121. Convinced by checking all current tests usages.
Tree-SHA512: c9e9a536a8721d1b3f267a66b40578b34948892301affdcad121ef8e02bf17037305d0dd53aa94b1b064753e66f9cfb31823b916b707a9d812627f502b818003
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/node.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp index 3828401642..dc5ecb9cbc 100644 --- a/src/rpc/node.cpp +++ b/src/rpc/node.cpp @@ -57,11 +57,9 @@ static RPCHelpMan setmocktime() throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime cannot be negative: %s.", time)); } SetMockTime(time); - auto node_context = util::AnyPtr<NodeContext>(request.context); - if (node_context) { - for (const auto& chain_client : node_context->chain_clients) { - chain_client->setMockTime(time); - } + const NodeContext& node_context{EnsureAnyNodeContext(request.context)}; + for (const auto& chain_client : node_context.chain_clients) { + chain_client->setMockTime(time); } return UniValue::VNULL; @@ -89,10 +87,9 @@ static RPCHelpMan mockscheduler() throw std::runtime_error("delta_time must be between 1 and 3600 seconds (1 hr)"); } - auto node_context = CHECK_NONFATAL(util::AnyPtr<NodeContext>(request.context)); - // protect against null pointer dereference - CHECK_NONFATAL(node_context->scheduler); - node_context->scheduler->MockForward(std::chrono::seconds(delta_seconds)); + const NodeContext& node_context{EnsureAnyNodeContext(request.context)}; + CHECK_NONFATAL(node_context.scheduler)->MockForward(std::chrono::seconds{delta_seconds}); + SyncWithValidationInterfaceQueue(); return UniValue::VNULL; }, |