diff --git a/scripts/test-all-features.sh b/scripts/test-all-features.sh index b20f26cd..5af69e5b 100755 --- a/scripts/test-all-features.sh +++ b/scripts/test-all-features.sh @@ -77,20 +77,20 @@ echo "# Target: ${TARGET}" echo "# Iterations: ${ITERATIONS}" echo "# Started: $(date -u +%Y-%m-%dT%H:%M:%SZ)" -# ── Auth ────────────────────────────────────────────────────────────────── -session_header=$(get_session) -SESSION=$(echo "$session_header" | sed -n 's/.*session=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]') -CSRF=$(echo "$session_header" | sed -n 's/.*csrf_token=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]') - -if [[ -z "$SESSION" ]]; then - echo "BAIL OUT! Cannot authenticate to ${TARGET}" - exit 1 -fi - for i in $(seq 1 "$ITERATIONS"); do echo "" echo "# ── Iteration ${i}/${ITERATIONS} [$(date +%H:%M:%S)] ──" + # Re-authenticate each iteration to handle backend restarts + session_header=$(get_session) + SESSION=$(echo "$session_header" | sed -n 's/.*session=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]') + CSRF=$(echo "$session_header" | sed -n 's/.*csrf_token=\([^;]*\).*/\1/p' | head -1 | tr -d '[:space:]') + + if [[ -z "$SESSION" ]]; then + tap_fail "auth-${i}" "Cannot authenticate" + continue + fi + # ── System Health ───────────────────────────────────────────────────── health=$(curl -s --max-time 5 "http://${TARGET}/health" 2>/dev/null || echo "fail") if [[ "$health" == "OK" ]]; then tap_ok "health-${i}"; else tap_fail "health-${i}" "$health"; fi @@ -153,7 +153,9 @@ for i in $(seq 1 "$ITERATIONS"); do fi # ── NIP-07 ──────────────────────────────────────────────────────────── - provider=$(curl -s --connect-timeout 5 "http://${TARGET}/app/mempool/" 2>/dev/null | grep -c "nostr-provider" || echo "0") + provider=$(curl -s --connect-timeout 5 "http://${TARGET}/app/mempool/" 2>/dev/null | grep -c "nostr-provider" 2>/dev/null || true) + provider=$(echo "$provider" | tr -d '[:space:]') + [[ -z "$provider" ]] && provider=0 if [[ "$provider" -gt 0 ]]; then tap_ok "nip07-provider-${i}" else