@@ -227,6 +227,9 @@ UniValue help(const JSONRPCRequest& jsonRequest)
227227UniValue stop (const JSONRPCRequest& jsonRequest)
228228{
229229 // Accept the deprecated and ignored 'detach' boolean argument
230+ // Also accept the hidden 'wait' integer argument (milliseconds)
231+ // For instance, 'stop 1000' makes the call wait 1 second before returning
232+ // to the client (intended for testing)
230233 if (jsonRequest.fHelp || jsonRequest.params .size () > 1 )
231234 throw std::runtime_error (
232235 RPCHelpMan{" stop" ,
@@ -235,6 +238,9 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
235238 // Event loop will exit after current HTTP requests have been handled, so
236239 // this reply will get back to the client.
237240 StartShutdown ();
241+ if (jsonRequest.params [0 ].isNum ()) {
242+ MilliSleep (jsonRequest.params [0 ].get_int ());
243+ }
238244 return " Bitcoin server stopping" ;
239245}
240246
@@ -264,7 +270,7 @@ static const CRPCCommand vRPCCommands[] =
264270 // --------------------- ------------------------ ----------------------- ----------
265271 /* Overall control/query calls */
266272 { " control" , " help" , &help, {" command" } },
267- { " control" , " stop" , &stop, {} },
273+ { " control" , " stop" , &stop, {" wait " } },
268274 { " control" , " uptime" , &uptime, {} },
269275};
270276// clang-format on
0 commit comments