91 lines
3.2 KiB
Bash
91 lines
3.2 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Lethean testnet network validation script
|
||
|
|
# Tests: node sync, mining, wallet, block propagation
|
||
|
|
#
|
||
|
|
# Usage: ./test-network.sh [compose-file]
|
||
|
|
# Default: docker-compose.nodes.yml
|
||
|
|
|
||
|
|
set -e
|
||
|
|
COMPOSE=${1:-docker-compose.nodes.yml}
|
||
|
|
|
||
|
|
echo "=== Lethean Network Test ==="
|
||
|
|
echo "Using: $COMPOSE"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Check all nodes are running
|
||
|
|
echo "1. Checking node health..."
|
||
|
|
for n in 1 2 3; do
|
||
|
|
port=$((46940 + (n-1)*10 + 1))
|
||
|
|
height=$(curl -s -X POST http://127.0.0.1:$port/json_rpc \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' 2>/dev/null | \
|
||
|
|
python3 -c "import sys,json; print(json.load(sys.stdin)['result']['height'])" 2>/dev/null)
|
||
|
|
echo " node$n (:$port): height=$height"
|
||
|
|
done
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "2. Checking P2P connectivity..."
|
||
|
|
peers=$(curl -s -X POST http://127.0.0.1:46941/json_rpc \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' 2>/dev/null | \
|
||
|
|
python3 -c "import sys,json; d=json.load(sys.stdin)['result']; print(f'out={d[\"outgoing_connections_count\"]} in={d[\"incoming_connections_count\"]}')" 2>/dev/null)
|
||
|
|
echo " node1 peers: $peers"
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "3. Testing getblocktemplate..."
|
||
|
|
template=$(curl -s -X POST http://127.0.0.1:46941/json_rpc \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"jsonrpc":"2.0","id":"0","method":"getblocktemplate","params":{"wallet_address":"iTHNUNiuu3VP1yy8xH2y5iQaABKXurdjqZmzFiBiyR4dKG3j6534e9jMriY6SM7PH8NibVwVWW1DWJfQEWnSjS8n3Wgx86pQpY"}}' 2>/dev/null | \
|
||
|
|
python3 -c "import sys,json; r=json.load(sys.stdin)['result']; print(f'height={r[\"height\"]} diff={r[\"difficulty\"]}')" 2>/dev/null)
|
||
|
|
echo " template: $template"
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "4. Starting mining on node1..."
|
||
|
|
curl -s -X POST http://127.0.0.1:46941/start_mining \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"miner_address":"iTHNUNiuu3VP1yy8xH2y5iQaABKXurdjqZmzFiBiyR4dKG3j6534e9jMriY6SM7PH8NibVwVWW1DWJfQEWnSjS8n3Wgx86pQpY","threads_count":4}' 2>/dev/null | python3 -m json.tool 2>/dev/null
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "5. Waiting 60s for blocks..."
|
||
|
|
sleep 60
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "6. Checking sync across nodes..."
|
||
|
|
heights=""
|
||
|
|
for n in 1 2 3; do
|
||
|
|
port=$((46940 + (n-1)*10 + 1))
|
||
|
|
h=$(curl -s -X POST http://127.0.0.1:$port/json_rpc \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' 2>/dev/null | \
|
||
|
|
python3 -c "import sys,json; print(json.load(sys.stdin)['result']['height'])" 2>/dev/null)
|
||
|
|
echo " node$n: height=$h"
|
||
|
|
heights="$heights $h"
|
||
|
|
done
|
||
|
|
|
||
|
|
# Check all nodes at same height
|
||
|
|
unique=$(echo $heights | tr ' ' '\n' | sort -u | wc -l)
|
||
|
|
if [ "$unique" -eq 1 ]; then
|
||
|
|
echo ""
|
||
|
|
echo " PASS: All nodes synced at same height"
|
||
|
|
else
|
||
|
|
echo ""
|
||
|
|
echo " WARN: Nodes at different heights (propagation delay normal)"
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "7. Checking HF status..."
|
||
|
|
curl -s -X POST http://127.0.0.1:46941/json_rpc \
|
||
|
|
-H 'Content-Type: application/json' \
|
||
|
|
-d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' 2>/dev/null | \
|
||
|
|
python3 -c "
|
||
|
|
import sys,json
|
||
|
|
d=json.load(sys.stdin)['result']
|
||
|
|
hf=[i for i,v in enumerate(d['is_hardfok_active']) if v]
|
||
|
|
print(f' Active HFs: {hf}')
|
||
|
|
print(f' PoS allowed: {d[\"pos_allowed\"]}')
|
||
|
|
print(f' Aliases: {d[\"alias_count\"]}')
|
||
|
|
"
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "=== Test Complete ==="
|