bridge.py:
- _send_over_link: splits TCP data into RNS.Packet.ENCRYPTED_MDU-sized chunks
before sending. RNS.Packet.pack() raises IOError on oversized data; a 32 KB
TCP read would silently kill the tunnel on any LoRa or constrained interface.
Order is safe — link is point-to-point, single sender per tunnel.
- Renamed RNS_BUFFER_SIZE → TCP_READ_SIZE (reads stay large for TCP efficiency;
only outbound RNS direction is chunked).
gossip.py:
- _build_ref_payloads: packs refs into JSON payloads that each fit within
ENCRYPTED_MDU. For >5 refs (>383 B), produces multiple packets. The receiver
handles each independently — each triggers a change check and potential sync.
- _broadcast and _send_initial_refs now use _build_ref_payloads instead of
building a single possibly-oversized payload.
tests:
- test_integration: set mock_pkt_cls.ENCRYPTED_MDU=383 so chunk size is correct
under patch; assert single-packet delivery for small payloads
- test_gossip: TestBuildRefPayloads — small fits in 1 packet, 20 refs split
across multiple packets all ≤ MDU, delta flag propagated to all chunks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FakeRNSNetwork routes announces and packets between instances in-process,
replacing the need for real RNS hardware in CI. Covers:
- Gossip: A broadcasts new refs → B receives packet → B triggers sync
- Gossip: repeated identical refs do not trigger a spurious sync
- Gossip: peer discovery via announce causes initial ref exchange
- Bridge: mutual discovery, NID extraction, de-duplication of auto_seed
- TCP tunnel: data forwarded from TCP socket to RNS Packet
- TCP tunnel: data received from RNS written back to TCP socket
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>