nsecbunkerd/tests
Padreug 1c16a2a4b7
Some checks failed
Docker image / build-and-push-image (push) Has been cancelled
fix(transport): harden RelayPool — connect timeout, stop-race, cross-relay dedup
Folds three medium findings from the transport review into the RelayPool:

- RP-4: connectOnce used the static Relay.connect(), which silently DROPS a
  {timeout} option in nostr-tools 2.20.0, so a black-holed TCP connect (SYN
  accepted, never upgraded) stalled that relay's loop for the OS socket timeout
  (minutes) with no retry. Now constructs the Relay and calls the instance
  .connect({ timeout: 5000 }), which honours the timeout → prompt reject + backoff.

- RP-2: connectOnce didn't re-check `stopped` after the await. If stop() ran
  while a connect was in flight, the resolved socket re-armed subscriptions on a
  relay we meant to abandon, leaked the socket, and hung connectLoop (its promise
  never resolved because onclose never fired). Now drops the socket cleanly and
  resolves if stopped mid-connect.

- RP-1: no cross-relay event dedup — a kind:24133 request published to N relays
  (the normal NIP-46 pattern), or re-delivered after a reconnect, drove the
  daemon handler + recordSigning N times, making rate caps bind ~N× tighter
  (fails closed, not open). Added a bounded (4000-id, ≈LRU) pool-wide seen-set;
  onevent fires at most once per event id. Closes the CS-4 replay vector too.

Test: tests/relay-pool.test.ts asserts a duplicate event id is delivered once.
relay 3 / nip46 1 / admin 2 green; daemon bundles; tsc at baseline.

Refs: transport review RP-1/RP-2/RP-4, CS-4; #42
2026-06-27 12:27:36 +02:00
..
helpers feat(transport): nostr-tools relay pool that re-subscribes on reconnect (#42) 2026-06-26 23:42:36 +02:00
acl.integration.test.ts fix(acl): hard-reject a lapsed token binding instead of prompting (#36) 2026-06-21 12:44:36 +02:00
admin-transport.test.ts feat(transport): port the admin RPC off NDK onto the relay pool (#42) 2026-06-27 01:23:53 +02:00
lifecycle.test.ts test(acl)(#25): extract pure grantIsLive/liveWhere + unit tests 2026-06-19 15:16:37 +02:00
nip46-backend.test.ts feat(transport): port the NIP-46 backend off NDK onto the relay pool (#42) 2026-06-27 00:29:02 +02:00
register-ts.cjs test(acl)(#29): DB-backed integration tests for checkIfPubkeyAllowed 2026-06-19 21:09:41 +00:00
relay-pool.test.ts fix(transport): harden RelayPool — connect timeout, stop-race, cross-relay dedup 2026-06-27 12:27:36 +02:00