Split renderFeed() into full rebuild + prependPostCard() on both feed.html and post.html. New live events now prepend a single card at the top of the feed without rebuilding existing cards, eliminating O(n) DOM rebuilds on every incoming event. DOM is trimmed to displayCount on overflow with renderedPostIds kept in sync. Full rebuild path preserved for See More, mute removal, bootstrap completion, and event mode. Also added implementation checklist to plans/long-running-memory-bloat-fix.md.
96 lines
2.4 KiB
Bash
Executable File
96 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# tests/broadcast-relay-test.sh
|
|
#
|
|
# Tests publishing a kind 1 note to each relay in tests/relays.json
|
|
# using nak, one relay at a time. Reports success/failure for each.
|
|
#
|
|
# Usage:
|
|
# ./tests/broadcast-relay-test.sh
|
|
#
|
|
# Requirements:
|
|
# - nak (https://github.com/fiatjaf/nak) installed and in PATH
|
|
# - tests/test-key.txt containing a hex private key
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
RELAYS_FILE="$SCRIPT_DIR/relays.json"
|
|
RESULTS_FILE="$SCRIPT_DIR/broadcast-relay-results.txt"
|
|
KEY_FILE="$SCRIPT_DIR/test-key.txt"
|
|
|
|
# Check for nak
|
|
if ! command -v nak &>/dev/null; then
|
|
echo "ERROR: nak is not installed."
|
|
exit 1
|
|
fi
|
|
|
|
# Check for key file
|
|
if [ ! -f "$KEY_FILE" ]; then
|
|
echo "ERROR: $KEY_FILE not found. Generate one with: nak key generate > $KEY_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
SEC=$(cat "$KEY_FILE" | tr -d '[:space:]')
|
|
|
|
# Extract relay URLs from the JSON file
|
|
echo "Extracting relay URLs from $RELAYS_FILE..."
|
|
mapfile -t RELAYS < <(python3 -c "
|
|
import json
|
|
with open('$RELAYS_FILE') as f:
|
|
data = json.load(f)
|
|
for tag in data:
|
|
if isinstance(tag, list) and len(tag) >= 2 and tag[0] == 'r':
|
|
print(tag[1])
|
|
")
|
|
|
|
TOTAL=${#RELAYS[@]}
|
|
echo "Found $TOTAL relay URLs"
|
|
echo ""
|
|
|
|
CONTENT="Broadcast relay test $(date -u +%Y-%m-%dT%H:%M:%SZ) — testing relay reachability via nak"
|
|
echo "Test content: $CONTENT"
|
|
echo ""
|
|
|
|
# Initialize results file
|
|
{
|
|
echo "# Broadcast Relay Test Results"
|
|
echo "# Date: $(date -u)"
|
|
echo "# Total relays: $TOTAL"
|
|
echo "# Test content: $CONTENT"
|
|
echo ""
|
|
} > "$RESULTS_FILE"
|
|
|
|
SUCCESS=0
|
|
FAILED=0
|
|
COUNT=0
|
|
|
|
for RELAY in "${RELAYS[@]}"; do
|
|
COUNT=$((COUNT + 1))
|
|
[ -z "$RELAY" ] && continue
|
|
|
|
printf "[%d/%d] %s ... " "$COUNT" "$TOTAL" "$RELAY"
|
|
|
|
RESULT=$(timeout 15 nak event --sec "$SEC" -c "$CONTENT" "$RELAY" 2>&1) || RESULT="FAILED: exit code $?"
|
|
|
|
if echo "$RESULT" | grep -qi "success"; then
|
|
echo "OK"
|
|
echo "OK: $RELAY" >> "$RESULTS_FILE"
|
|
SUCCESS=$((SUCCESS + 1))
|
|
elif echo "$RESULT" | grep -qi "error\|failed\|refused\|timeout\|reject\|blocked"; then
|
|
echo "FAIL"
|
|
echo "FAIL: $RELAY — $RESULT" >> "$RESULTS_FILE"
|
|
FAILED=$((FAILED + 1))
|
|
else
|
|
echo "UNKNOWN"
|
|
echo "UNKNOWN: $RELAY — $RESULT" >> "$RESULTS_FILE"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "=== Summary ==="
|
|
echo "Total: $TOTAL"
|
|
echo "Success: $SUCCESS"
|
|
echo "Failed: $FAILED"
|
|
echo ""
|
|
echo "Full results: $RESULTS_FILE"
|