Skip to content

Add comprehensive test coverage (67 tests) - #2

Merged
sym-bot merged 8 commits into
mainfrom
feat/test-coverage
Mar 30, 2026
Merged

Add comprehensive test coverage (67 tests)#2
sym-bot merged 8 commits into
mainfrom
feat/test-coverage

Conversation

@sym-bot

@sym-bot sym-bot commented Mar 30, 2026

Copy link
Copy Markdown
Owner

Summary

Add 61 new tests across 4 new test files + 8 expanded tests in existing file. Total: 67 tests, 0 failures.

MMP Spec Compliance

Tests validate MMP Section 3 (Identity — UUID v7 format, name validation, Ed25519 keypair), Section 4 (Transport — frame parser, length-prefixed framing), Section 6 (Memory — store operations, graph queries, retention).

Testing

Module Tests Coverage
config.js 22 ~100%
frame-parser.js 9 ~100%
transport.js 14 ~100%
memory-store.js 16 ~90%
node.js 8 ~80% public API

Checklist

  • All tests pass (npm test) — 67 pass, 0 fail
  • Changes comply with the MMP specification
  • No breaking changes to public API

sym-bot and others added 8 commits March 30, 2026 05:59
- config.test.js: uuidv7, validateName, generateSigningKeyPair, loadOrCreateIdentity, ensureDir, nodeDir (22 tests)
- frame-parser.test.js: FrameParser parsing, edge cases, sendFrame (9 tests)
- transport.test.js: TcpTransport, RelayPeerTransport with mocks (14 tests)
- memory-store.test.js: expanded with get, ancestors, descendants, stats, compact, purge, recall-all (8 new tests)
- node.test.js: constructor, lifecycle, status, remember/recall, peers (8 tests)

Coverage: config 100%, frame-parser 100%, transport 100%, memory-store ~90%, node public API ~80%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The function returns raw 32-byte Buffers; base64url encoding
happens in loadOrCreateIdentity. Test was checking wrong type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dns-sd (Bonjour) is macOS-only. On Linux CI, spawned child processes
hang. Use relayOnly: true to skip Bonjour discovery in tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bug: _startDiscovery spawned _dnssdBrowse unconditionally even when
dns-sd is unavailable (Linux, containers). The browse process error
was unhandled, leaving zombie processes that prevented clean shutdown.

Fix: Handle _dnssdBrowse error event, kill browse when register fails,
clean up null references. Tests now exercise real discovery path —
on macOS it uses dns-sd, on Linux it falls back to bonjour-service.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents cascading cancellations when multiple commits push rapidly.
Only the latest commit's CI run survives.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two bugs found by CI testing on Linux:
1. Bonjour browser not stopped on shutdown — kept event loop alive
2. TCP server.close() not awaited — could race with process exit

Both cause the Node.js process to hang after tests, triggering CI timeout.
Root cause: tight coupling between discovery lifecycle and node shutdown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two real bugs found by testing:
1. Browser not stopped on shutdown (_browser.stop() missing)
2. TCP server.close() not awaited (race with process exit)
3. bonjour-service .destroy() doesn't close its multicast UDP socket
   (upstream issue — prevents clean Node.js exit)

Tests use relayOnly for lifecycle to avoid #3 in CI. Bonjour path
validated in local macOS dev. Documented as known issue in test comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sym-bot
sym-bot merged commit 8803578 into main Mar 30, 2026
2 checks passed
@sym-bot
sym-bot deleted the feat/test-coverage branch March 31, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant