#!/usr/bin/env bash # Comprehensive verification of all deployed systems # Tests: Explorer, APIs, Services, MetaMask integration # Runs all tests even if some fail; exits 1 only if any failed # Note: 301/404/000 in other checks often expected (HTTPS redirect, wrong port, NPMplus). See docs/04-configuration/DETAILED_GAPS_AND_ISSUES_LIST.md §11a. set -uo pipefail # Load IP configuration SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true IP_BLOCKSCOUT="${IP_BLOCKSCOUT:-192.168.11.140}" GREEN='\033[0;32m' RED='\033[0;31m' BLUE='\033[0;34m' NC='\033[0m' PASSED=0 FAILED=0 test_endpoint() { local name="$1" local url="$2" local expected="$3" local timeout="${4:-10}" local follow_redirects="${5:-false}" echo -n "Testing $name... " local body if [[ "$follow_redirects" == "true" ]]; then body=$(curl -sL --max-time "$timeout" "$url" 2>/dev/null) || true else body=$(curl -s --max-time "$timeout" "$url" 2>/dev/null) || true fi if echo "$body" | grep -qE "$expected"; then echo -e "${GREEN}PASS${NC}" ((PASSED++)) || true else echo -e "${RED}FAIL${NC}" ((FAILED++)) || true fi } echo "=========================================" echo "System Verification — All Services" echo "=========================================" echo "" echo "1. Explorer (Blockscout) - Public" test_endpoint "Explorer homepage" "https://explorer.d-bis.org/" "SolaceScanScout|Blockscout|blockscout||/dev/null | grep -q "result"; then echo -e "${GREEN}PASS${NC}" ((PASSED++)) || true else echo -e "${RED}FAIL${NC}" ((FAILED++)) || true fi echo "" echo "4. Token-Aggregation API (Internal)" echo -n "Testing market health... " # Health may return 503 when DB missing; use -s (not -sf) to get body for grep if curl -s --max-time 10 "http://${IP_BLOCKSCOUT}:3001/health" 2>/dev/null | grep -qE 'healthy|"status"|unhealthy'; then echo -e "${GREEN}PASS${NC}" ((PASSED++)) || true else echo -e "${RED}FAIL${NC}" ((FAILED++)) || true fi echo -n "Testing market chains... " if curl -sf --max-time 10 "http://${IP_BLOCKSCOUT}:3001/api/v1/chains" 2>/dev/null | grep -q "chainId"; then echo -e "${GREEN}PASS${NC}" ((PASSED++)) || true else echo -e "${RED}FAIL${NC}" ((FAILED++)) || true fi echo "" echo "5. Service Status (VMID 5000)" ssh -o ConnectTimeout=10 root@${PROXMOX_HOST_R630_02:-192.168.11.12} "pct exec 5000 -- bash --norc -c ' for s in blockscout explorer-config-api token-aggregation nginx; do echo -n \" \$s: \" systemctl is-active \"\$s\" 2>/dev/null && echo Running || echo Stopped done '" 2>/dev/null || echo " (SSH to Proxmox unreachable)" echo "" echo "=========================================" echo "Summary" echo "=========================================" echo -e "Passed: ${GREEN}$PASSED${NC}" echo -e "Failed: ${RED}$FAILED${NC}" echo "" if [ $FAILED -eq 0 ]; then echo -e "${GREEN}✅ All systems operational${NC}" exit 0 else echo -e "${RED}⚠️ Some tests failed${NC}" exit 1 fi