Files
udp_nostr/src/test_local.sh
T
2026-08-12 16:34:22 -04:00

32 lines
729 B
Bash

#!/bin/bash
# Test the UDP Nostr sender/receiver locally
set -e
PORT=8891
cd "$(dirname "$0")"
# Kill any leftover process on the port
fuser -k ${PORT}/udp 2>/dev/null || true
sleep 0.5
# Start receiver in background, capture output
python3 -u udp_nostr_recv.py 0.0.0.0 $PORT > /tmp/udp_recv_test.txt 2>&1 &
RECV_PID=$!
sleep 1
# Send an event
nak event -k 1 -c "Hello via UDP Nostr!" --sec $(nak key generate) 2>/dev/null | python3 udp_nostr_send.py 127.0.0.1 $PORT
# Wait for receiver to process
sleep 3
# Show receiver output
echo ""
echo "========== RECEIVER OUTPUT =========="
cat /tmp/udp_recv_test.txt
echo "========== END =========="
# Cleanup
kill $RECV_PID 2>/dev/null || true
wait $RECV_PID 2>/dev/null || true