Created
November 25, 2025 19:29
-
-
Save johnnyasantoss/c41231d0e6879e92336441ded03a4e5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BITCOIND="bitcoind" | |
| BITCOINCLI="bitcoin-cli" | |
| GREP="grep" | |
| DATADIR="/tmp/btc_stopatheight_test" | |
| EXPECTED_HEIGHT=10 | |
| ITERATIONS=100 | |
| BITCOIN_SHARED_OPTS="-signet -signetchallenge=xx -addnode=a.b.c.d:38333 -datadir=$DATADIR" | |
| if ! command -v $BITCOIND &> /dev/null; then | |
| echo "Error: bitcoind not found." | |
| exit 1 | |
| fi | |
| for ((i=1;i<=ITERATIONS;i++)); do | |
| echo "Iteration $i of $ITERATIONS" | |
| rm -rf "$DATADIR" | |
| mkdir -p "$DATADIR" | |
| $BITCOIND $BITCOIN_SHARED_OPTS -daemon -stopatheight=$EXPECTED_HEIGHT > /dev/null 2>&1 | |
| # Wait for bitcoind to start and then exit | |
| sleep 2 | |
| while pgrep -f "$BITCOIND $BITCOIN_SHARED_OPTS" > /dev/null; do | |
| sleep 1 | |
| done | |
| LOG_FILE="$DATADIR/signet/debug.log" | |
| if [ ! -f "$LOG_FILE" ]; then | |
| echo "PANIC: Log file not found. Bitcoind failed to start or write logs." | |
| exit 1 | |
| fi | |
| if ! $GREP -q "height=$EXPECTED_HEIGHT" "$LOG_FILE"; then | |
| echo "PANIC: Expected height $EXPECTED_HEIGHT not found in logs." | |
| exit 1 | |
| fi | |
| NEXT_HEIGHT=$((EXPECTED_HEIGHT + 1)) | |
| if $GREP -q "height=$NEXT_HEIGHT" "$LOG_FILE"; then | |
| echo "PANIC: Found height $NEXT_HEIGHT in logs (went too far)." | |
| exit 1 | |
| fi | |
| done | |
| echo "Test completed successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment