fix(test): restore the ecash network before bouncing the service

The restore proof's cleanup set the network back *after* restarting
archipelago, so the call landed on a socket that wasn't listening yet
and failed silently. A fully green run left the node parked on testnet —
the one outcome a cleanup path must never produce, and worse for being
invisible.

Network first, while the RPC is still up; then the wallet file, then the
restart, then wait for the service back so a check running straight
afterwards doesn't meet a dead socket.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
archipelago
2026-08-17 09:15:31 -04:00
co-authored by Claude Opus 5
parent 212e349b19
commit 603291008b
+14 -3
View File
@@ -37,13 +37,24 @@ ok() { PASS=$((PASS+1)); printf ' \033[32mPASS\033[0m %s\n' "$*"; }
bad() { FAIL=$((FAIL+1)); printf ' \033[31mFAIL\033[0m %s\n' "$*"; } bad() { FAIL=$((FAIL+1)); printf ' \033[31mFAIL\033[0m %s\n' "$*"; }
cleanup() { cleanup() {
# Put the wallet back before anything else — this is the only step whose # Network first, while the service is still up: the restart below tears the
# failure could actually cost someone coins. # RPC out from under us, and an ecash-set-network fired at a socket that
# isn't listening yet fails silently — which left the node parked on testnet
# after an otherwise green run.
[ -n "$ORIGINAL_NETWORK" ] && rpc wallet.ecash-set-network "{\"network\":\"$ORIGINAL_NETWORK\"}" >/dev/null 2>&1
# Then put the wallet back. This is the only step whose failure could
# actually cost someone coins, so it is not conditional on the above.
if [ -n "$BACKUP" ] && [ -f "$BACKUP" ]; then if [ -n "$BACKUP" ] && [ -f "$BACKUP" ]; then
sudo mv -f "$BACKUP" "$WALLET" && printf 'restored the testnet wallet file\n' sudo mv -f "$BACKUP" "$WALLET" && printf 'restored the testnet wallet file\n'
sudo systemctl restart archipelago >/dev/null 2>&1 sudo systemctl restart archipelago >/dev/null 2>&1
# Wait for it back, so a caller running another check straight after
# doesn't meet a dead socket.
for _ in $(seq 1 30); do
curl -s --max-time 3 -o /dev/null "$BASE/" && break
sleep 2
done
fi fi
[ -n "$ORIGINAL_NETWORK" ] && rpc wallet.ecash-set-network "{\"network\":\"$ORIGINAL_NETWORK\"}" >/dev/null 2>&1
rm -f "$JAR" rm -f "$JAR"
} }
trap cleanup EXIT trap cleanup EXIT