From 274c6714cacc567087a01f954826f498ff560463 Mon Sep 17 00:00:00 2001 From: Dimitrios Siganos Date: Tue, 30 Apr 2024 14:47:44 +0100 Subject: [PATCH] A system test to exercise the rpc stop command (#4573) Introduce a systest case for rpc stop command --- nano/rpc/rpc.cpp | 1 + systest/rpc_stop.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 systest/rpc_stop.sh diff --git a/nano/rpc/rpc.cpp b/nano/rpc/rpc.cpp index c2cae1e3e9..5b5d84ecde 100644 --- a/nano/rpc/rpc.cpp +++ b/nano/rpc/rpc.cpp @@ -50,6 +50,7 @@ void nano::rpc::start () logger.critical (nano::log::type::rpc, "Error while binding for RPC on port: {} ({})", endpoint.port (), ec.message ()); throw std::runtime_error (ec.message ()); } + logger.info (nano::log::type::rpc, "RPC listening address: {}", fmt::streamed (acceptor.local_endpoint ())); acceptor.listen (); accept (); } diff --git a/systest/rpc_stop.sh b/systest/rpc_stop.sh new file mode 100755 index 0000000000..bee54b88ad --- /dev/null +++ b/systest/rpc_stop.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -eux + +DATADIR=$(mktemp -d) + +# Start the node in daemon mode in the background +$NANO_NODE_EXE --daemon --network dev --data_path $DATADIR --config rpc.enable=true --rpcconfig enable_control=true & +NODE_PID=$! + +# Allow some time for the node to start up completely +sleep 10 + +# Send the stop rpc command +curl -g -d '{ "action": "stop" }' '[::1]:45000' + +# Check if the process has stopped using a timeout to avoid infinite waiting +if wait $NODE_PID; then + echo "Node stopped successfully" +else + echo "Node did not stop as expected" + exit 1 +fi