#!/usr/bin/env bash # E2E: every public RPC FQDN — HTTP JSON-RPC eth_chainId (+ WSS where listed). # Exit 0 only if all HTTP checks pass; WSS failures warn unless STRICT_WSS=1 (then exit 1). # # Usage: bash scripts/verify/check-rpc-fqdns-e2e.sh # Env: RPC_TIMEOUT_SEC (default 25), STRICT_WSS=1 to fail on wscat errors set -euo pipefail TO="${RPC_TIMEOUT_SEC:-25}" BODY='{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' # Chain 138 EXPECT='0x8a' # HTTP JSON-RPC hostnames (inventory: verify-end-to-end-routing.sh + RPC_ENDPOINTS_MASTER + NPM tw-core / core-2) HTTP_FQDNS=( rpc-http-pub.d-bis.org rpc.d-bis.org rpc2.d-bis.org rpc-http-prv.d-bis.org rpc-fireblocks.d-bis.org rpc.public-0138.defi-oracle.io rpc.defi-oracle.io rpc-alltra.d-bis.org rpc-alltra-2.d-bis.org rpc-alltra-3.d-bis.org rpc-hybx.d-bis.org rpc-hybx-2.d-bis.org rpc-hybx-3.d-bis.org rpc.tw-core.d-bis.org rpc-core-2.d-bis.org rpc-core.d-bis.org ) # WebSocket RPC hostnames (wss://) WS_FQDNS=( rpc-ws-pub.d-bis.org ws.rpc.d-bis.org ws.rpc2.d-bis.org rpc-ws-prv.d-bis.org ws.rpc-fireblocks.d-bis.org wss.defi-oracle.io wss.tw-core.d-bis.org ) RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "RPC FQDN E2E — eth_chainId (HTTP) + WSS smoke" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" http_fail=0 echo -e "${BLUE}--- HTTP (POST / JSON-RPC) ---${NC}" for host in "${HTTP_FQDNS[@]}"; do url="https://${host}" if ! getent ahosts "$host" >/dev/null 2>&1; then echo -e "${YELLOW}SKIP${NC} $url — hostname does not resolve (add DNS or use Core IP :8545)" continue fi resp=$(mktemp) code=$(curl -sS -m "$TO" -X POST "$url" \ -H 'Content-Type: application/json' \ -d "$BODY" \ -k -w '%{http_code}' -o "$resp" 2>/dev/null || echo "000") cid=$(jq -r '.result // empty' "$resp" 2>/dev/null || true) err=$(head -c 120 "$resp" 2>/dev/null | tr -d '\r\n') rm -f "$resp" if [[ "$code" == "200" && "$cid" == "$EXPECT" ]]; then echo -e "${GREEN}OK${NC} $url chainId=$cid" elif [[ "$code" == "200" && -n "$cid" ]]; then echo -e "${YELLOW}WARN${NC} $url HTTP $code chainId=$cid (expected $EXPECT)" ((http_fail++)) || true else echo -e "${RED}FAIL${NC} $url HTTP $code ${err}" ((http_fail++)) || true fi done echo "" echo -e "${BLUE}--- WebSocket (wscat eth_chainId) ---${NC}" ws_fail=0 if ! command -v wscat >/dev/null 2>&1; then echo -e "${YELLOW}SKIP${NC} wscat not installed (npm i -g wscat)" ws_fail=0 else for host in "${WS_FQDNS[@]}"; do if out=$(timeout "$((TO + 5))" wscat -n -c "wss://${host}" -x "$BODY" -w 8 2>&1); then if echo "$out" | grep -q '"result"'; then echo -e "${GREEN}OK${NC} wss://${host}" else echo -e "${YELLOW}OK*${NC} wss://${host} (connected, no JSON line)" fi else echo -e "${RED}FAIL${NC} wss://${host} $(echo "$out" | tail -1)" ((ws_fail++)) || true fi done fi echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" if [[ "$http_fail" -eq 0 ]]; then echo -e "${GREEN}HTTP: all passed ($EXPECT)${NC}" else echo -e "${RED}HTTP: $http_fail failure(s)${NC}" fi if [[ "${STRICT_WSS:-0}" == "1" ]] && [[ "$ws_fail" -gt 0 ]]; then echo -e "${RED}WSS: $ws_fail failure(s) (STRICT_WSS=1)${NC}" exit 1 fi if [[ "$http_fail" -gt 0 ]]; then exit 1 fi echo -e "${GREEN}Done.${NC}" exit 0