Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A system test to exercise the rpc stop command #4573

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nano/rpc/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}
Expand Down
22 changes: 22 additions & 0 deletions systest/rpc_stop.sh
Original file line number Diff line number Diff line change
@@ -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
Loading