Skip to content
Open
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
18 changes: 4 additions & 14 deletions rpc-integration-test/run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

TESTDIR=/tmp/rust_bitcoincore_rpc_test
TESTDIR=/tmp/rust_dashcore_rpc_test

rm -rf ${TESTDIR}
mkdir -p ${TESTDIR}/1 ${TESTDIR}/2

# To kill any remaining open bitcoind.
killall -9 bitcoind
# To kill any remaining open dashd.
killall -9 dashd
Comment on lines +8 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid killall -9 dashd; scope cleanup to this script.

killall -9 may nuke a developer’s local node. Remove this and rely on PID-scoped cleanup with TERM + forced KILL fallback in a trap.

-# To kill any remaining open dashd.
-killall -9 dashd

Add a trap after spawning processes (outside selected lines):

cleanup() {
  # Try graceful shutdown first
  kill -TERM ${PID2:-} ${PID1:-} 2>/dev/null || true
  wait ${PID2:-} ${PID1:-} 2>/dev/null || true
}
trap cleanup EXIT INT TERM
🤖 Prompt for AI Agents
In rpc-integration-test/run.sh around lines 8 to 9, remove the unconditional
global killall -9 dashd and instead implement PID-scoped cleanup: after you
spawn background processes capture their PIDs, add a trap for EXIT/INT/TERM that
first attempts a graceful kill -TERM on those PIDs, waits for them, and if they
do not exit escalate to kill -9 as a fallback; place the trap setup after the
processes are spawned so it can reference the actual PID variables and suppress
errors on missing PIDs.


bitcoind -regtest \
-datadir=${TESTDIR}/1 \
Expand All @@ -18,17 +18,7 @@ PID1=$!
# Make sure it's listening on its p2p port.
sleep 3

BLOCKFILTERARG=""
if bitcoind -version | grep -q "v0\.\(19\|2\)"; then
BLOCKFILTERARG="-blockfilterindex=1"
fi

FALLBACKFEEARG=""
if bitcoind -version | grep -q "v0\.2"; then
FALLBACKFEEARG="-fallbackfee=0.00001000"
fi

bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \
dashd -regtest \
-datadir=${TESTDIR}/2 \
-connect=127.0.0.1:12348 \
-rpcport=12349 \
Expand Down
Loading