Skip to content
Merged
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
55 changes: 55 additions & 0 deletions scripts/test-validatord-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Integration test script for validatord using bitcoind regtest mode.
# This script validates that the validator daemon can interact with a local
# bitcoin regtest network.

set -e

echo "=== Validatord Integration Test (regtest) ==="

# Check required environment variables
if [ -z "${BITCOIND_RPCURL}" ]; then
echo "BITCOIND_RPCURL environment variable is not set"
exit 1
fi

echo "Using BITCOIND_RPCURL: ${BITCOIND_RPCURL}"

# Check if the validatord binary exists
if [ ! -f "./validatord" ]; then
echo "Error: validatord binary not found. Please build it first."
exit 1
fi

echo "Found validatord binary"

# Run the validatord binary to verify it starts correctly
echo "Starting validatord..."
./validatord &
VALIDATORD_PID=$!

# Wait for validatord to initialize with retry logic
MAX_RETRIES=10
RETRY_DELAY=1
for i in $(seq 1 $MAX_RETRIES); do
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The loop variable i is used for counting but $(seq 1 $MAX_RETRIES) creates a subshell. In bash scripts, prefer the more efficient C-style for loop: for ((i=1; i<=MAX_RETRIES; i++)).

Suggested change
for i in $(seq 1 $MAX_RETRIES); do
for ((i=1; i<=MAX_RETRIES; i++)); do

Copilot uses AI. Check for mistakes.
if kill -0 $VALIDATORD_PID 2>/dev/null; then
echo "Validatord is running (PID: $VALIDATORD_PID, attempt $i)"
# Stop the process gracefully
kill $VALIDATORD_PID 2>/dev/null || true
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

Using kill without a signal flag sends SIGTERM, but the comment says 'gracefully'. Consider making this explicit by using kill -TERM or kill -15 to clearly document the graceful shutdown intent.

Suggested change
kill $VALIDATORD_PID 2>/dev/null || true
kill -TERM "$VALIDATORD_PID" 2>/dev/null || true

Copilot uses AI. Check for mistakes.
wait $VALIDATORD_PID 2>/dev/null || true
echo "Validatord stopped"
break
fi
if [ $i -eq 1 ]; then
# First attempt - process may have already exited successfully
echo "Validatord exited (this may be expected for short-lived initialization)"
break
fi
sleep $RETRY_DELAY
done
Comment on lines +28 to +49
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The test logic always reports success regardless of whether validatord actually runs. If the process exits immediately on all retry attempts (after attempt 1), the loop completes without breaking, but the test still exits with success. The script should explicitly verify that the daemon ran successfully at least once and fail if it never started properly.

Copilot uses AI. Check for mistakes.

echo ""
echo "=== Integration Test Complete ==="
echo "All checks passed!"

exit 0
Loading