Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 3, 2026

Adds integration test script to validate that the validatord daemon can start and interact with a Bitcoin regtest network.

Changes

  • scripts/test-validatord-integration.sh: New integration test script with:
    • Environment validation (BITCOIND_RPCURL required)
    • Binary existence check before execution
    • Background daemon startup with PID tracking
    • Retry loop (10 attempts, 1s intervals) to verify process initialization
    • Graceful shutdown on test completion
    • Handles short-lived initialization exits (first-attempt tolerance)
# Usage
export BITCOIND_RPCURL="http://user:pass@localhost:18443"
./scripts/test-validatord-integration.sh

Script assumes validatord binary exists in CWD. Exits cleanly after verifying daemon can start successfully.

Original prompt

#!/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
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
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

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

exit 0


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: dreadwitdastacc-IFA <243488924+dreadwitdastacc-IFA@users.noreply.github.com>
Copilot AI changed the title [WIP] Add integration test script for validatord with regtest Add validatord integration test for Bitcoin regtest interaction Jan 3, 2026
@dreadwitdastacc-IFA
Copy link
Owner

@copilot # GitHub CLI api

https://cli.github.com/manual/gh_api

gh api
--method POST
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
/repos/OWNER/REPO/actions/jobs/JOB_ID/rerun

@dreadwitdastacc-IFA
Copy link
Owner

@copilot can you fix then both # GitHub CLI api

https://cli.github.com/manual/gh_api

gh api
-H "Accept: application/vnd.github+json"
-H "X-GitHub-Api-Version: 2022-11-28"
/repos/OWNER/REPO/actions/runs

Copy link
Contributor Author

Copilot AI commented Jan 3, 2026

@copilot can you fix then both # GitHub CLI api

https://cli.github.com/manual/gh_api

...

I'd be happy to help, but I need clarification on what you'd like me to fix. Could you please specify:

  1. What "both" refers to?
  2. Are you asking me to integrate the GitHub CLI API examples into the integration test script, or is this about something else?

The current PR only adds the scripts/test-validatord-integration.sh file for testing the validatord daemon.

@dreadwitdastacc-IFA dreadwitdastacc-IFA marked this pull request as ready for review January 4, 2026 08:57
Copilot AI review requested due to automatic review settings January 4, 2026 08:57
@dreadwitdastacc-IFA dreadwitdastacc-IFA merged commit 9c050c9 into Dreadwitdastacc-Ifawole Jan 4, 2026
0 of 4 checks passed
@dreadwitdastacc-IFA dreadwitdastacc-IFA deleted the copilot/add-integration-test-validatord branch January 4, 2026 08:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an integration test script to verify that the validatord daemon can successfully start and interact with a Bitcoin regtest network. The test provides automated validation of the daemon's basic startup functionality in a local development environment.

Key Changes:

  • Introduces a new bash-based integration test script with environment validation and daemon lifecycle management
  • Implements a retry mechanism to handle race conditions during daemon initialization
  • Provides clear error messaging for missing dependencies (binary, environment variables)

Comment on lines +28 to +49
./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
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
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
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.
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 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants