test(broker): smoke test for hello + direct message flow
Some checks failed
CI / Tests / 🧪 Test (push) Has been cancelled
Some checks failed
CI / Tests / 🧪 Test (push) Has been cancelled
Adds scripts/{seed-test-mesh,peer-a,peer-b,smoke-test}.ts|.sh that
prove an end-to-end message flow works against a real Postgres:
- seed-test-mesh.ts creates user+mesh+2 members with deterministic
hex pubkeys ("aa..aa", "bb..bb"), writes seed JSON to stdout
- peer-a.ts sends hello then a direct "send" message to peer B's
pubkey with fake ciphertext "hello-from-a"
- peer-b.ts sends hello, waits up to 5s for a push, asserts
senderPubkey matches peer A, exits 0/1
- smoke-test.sh wires the three together
Verified flow: hello registers presence row → send queues into
mesh.message_queue → fanout matches connected peer by pubkey →
drainForMember joins on mesh.member for senderPubkey → push lands
with ciphertext + correct sender attribution.
Also fixes a date-serialization bug that blocked the first run:
applyPendingHookStatus used `sql${col} >= ${jsDate}` which passed
JS Date.toString() to Postgres (failed to parse). Replaced raw
sql`` template with typed gte/desc/isNotNull operators from
drizzle-orm. Same fix applied in sweepPendingStatuses.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
41
apps/broker/scripts/smoke-test.sh
Executable file
41
apps/broker/scripts/smoke-test.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# End-to-end smoke test for the broker.
|
||||
#
|
||||
# Flow:
|
||||
# 1. Seed a test mesh with 2 members → writes /tmp/smoke-seed.json
|
||||
# 2. Start peer B (receiver) in background
|
||||
# 3. Start peer A (sender)
|
||||
# 4. Wait for B → exit code is the test result
|
||||
#
|
||||
# Assumes: broker is running on ws://localhost:7900/ws, DATABASE_URL
|
||||
# is in env. Run from the broker workspace:
|
||||
# cd apps/broker && ./scripts/smoke-test.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "── seeding test mesh ──"
|
||||
bun "$DIR/seed-test-mesh.ts" > /tmp/smoke-seed.json
|
||||
cat /tmp/smoke-seed.json
|
||||
|
||||
echo ""
|
||||
echo "── starting peer-b (receiver) ──"
|
||||
bun "$DIR/peer-b.ts" &
|
||||
B_PID=$!
|
||||
|
||||
sleep 1
|
||||
|
||||
echo ""
|
||||
echo "── starting peer-a (sender) ──"
|
||||
bun "$DIR/peer-a.ts"
|
||||
|
||||
echo ""
|
||||
echo "── waiting for peer-b ──"
|
||||
if wait $B_PID; then
|
||||
echo "✓ smoke test PASSED"
|
||||
exit 0
|
||||
else
|
||||
echo "✗ smoke test FAILED"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user