| 741 | static RPCHelpMan echojson() { return echo("echojson"); } |
| 742 | |
| 743 | static RPCHelpMan echoipc() |
| 744 | { |
| 745 | return RPCHelpMan{ |
| 746 | "echoipc", |
| 747 | "\nEcho back the input argument, passing it through a spawned process in a multiprocess build.\n" |
| 748 | "This command is for testing.\n", |
| 749 | {{"arg", RPCArg::Type::STR, RPCArg::Optional::NO, "The string to echo",}}, |
| 750 | RPCResult{RPCResult::Type::STR, "echo", "The echoed string."}, |
| 751 | RPCExamples{HelpExampleCli("echo", "\"Hello world\"") + |
| 752 | HelpExampleRpc("echo", "\"Hello world\"")}, |
| 753 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { |
| 754 | interfaces::Init& local_init = *EnsureAnyNodeContext(request.context).init; |
| 755 | std::unique_ptr<interfaces::Echo> echo; |
| 756 | if (interfaces::Ipc* ipc = local_init.ipc()) { |
| 757 | // Spawn a new bitcoin-node process and call makeEcho to get a |
| 758 | // client pointer to a interfaces::Echo instance running in |
| 759 | // that process. This is just for testing. A slightly more |
| 760 | // realistic test spawning a different executable instead of |
| 761 | // the same executable would add a new bitcoin-echo executable, |
| 762 | // and spawn bitcoin-echo below instead of bitcoin-node. But |
| 763 | // using bitcoin-node avoids the need to build and install a |
| 764 | // new executable just for this one test. |
| 765 | auto init = ipc->spawnProcess("bitcoin-node"); |
| 766 | echo = init->makeEcho(); |
| 767 | ipc->addCleanup(*echo, [init = init.release()] { delete init; }); |
| 768 | } else { |
| 769 | // IPC support is not available because this is a bitcoind |
| 770 | // process not a bitcoind-node process, so just create a local |
| 771 | // interfaces::Echo object and return it so the `echoipc` RPC |
| 772 | // method will work, and the python test calling `echoipc` |
| 773 | // can expect the same result. |
| 774 | echo = local_init.makeEcho(); |
| 775 | } |
| 776 | return echo->echo(request.params[0].get_str()); |
| 777 | }, |
| 778 | }; |
| 779 | } |
| 780 | |
| 781 | static UniValue SummaryToJSON(const IndexSummary&& summary, std::string index_name) |
| 782 | { |
nothing calls this directly
no test coverage detected