Skip to content

Commit 2bcd953

Browse files
fanquakevijaydasmp
authored andcommitted
Merge bitcoin#28118: test: Add SyncWithValidationInterfaceQueue to mockscheduler RPC
fabef12 refactor: Use EnsureAnyNodeContext (MarcoFalke) fa16406 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 fabef12 furszy: Code review ACK fabef12. Convinced by checking all current tests usages. Tree-SHA512: c9e9a536a8721d1b3f267a66b40578b34948892301affdcad121ef8e02bf17037305d0dd53aa94b1b064753e66f9cfb31823b916b707a9d812627f502b818003
1 parent a0c02e8 commit 2bcd953

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/rpc/node.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,9 @@ static RPCHelpMan setmocktime()
272272
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime cannot be negative: %s.", time));
273273
}
274274
SetMockTime(time);
275-
if (auto* node_context = GetContext<NodeContext>(request.context)) {
276-
for (const auto& chain_client : node_context->chain_clients) {
277-
chain_client->setMockTime(time);
278-
}
275+
const NodeContext& node_context{EnsureAnyNodeContext(request.context)};
276+
for (const auto& chain_client : node_context.chain_clients) {
277+
chain_client->setMockTime(time);
279278
}
280279

281280
return UniValue::VNULL;
@@ -846,10 +845,9 @@ static RPCHelpMan mockscheduler()
846845
throw std::runtime_error("delta_time must be between 1 and 3600 seconds (1 hr)");
847846
}
848847

849-
auto* node_context = CHECK_NONFATAL(GetContext<NodeContext>(request.context));
850-
// protect against null pointer dereference
851-
CHECK_NONFATAL(node_context->scheduler);
852-
node_context->scheduler->MockForward(std::chrono::seconds(delta_seconds));
848+
const NodeContext& node_context{EnsureAnyNodeContext(request.context)};
849+
CHECK_NONFATAL(node_context.scheduler)->MockForward(std::chrono::seconds{delta_seconds});
850+
SyncWithValidationInterfaceQueue();
853851

854852
return UniValue::VNULL;
855853
},

0 commit comments

Comments
 (0)