test(core): direct unit tests for RoomProtocol's wire-verb handlers and token verification - #127
Merged
Merged
Conversation
…cation directly RoomProtocol was previously exercised only through real two-peer TCP/TLS integration tests, which cover the happy path end-to-end but not most individual error codes, optional-field spreads, and edge branches. RoomProtocolDeps is a narrow, injectable surface built exactly for direct testing, but token verification here is genuinely cryptographic (verifyRoomToken), so tests use real identities (generateIdentity/ toIdentityPort) and real minted tokens (mintCapabilityToken) rather than opaque placeholders, unlike room-messaging.ts's sending side. Split across two files to stay under this repo's max-lines cap. room-protocol.test.ts covers handleRoomSend, handleRoomRead, handleRoomMembers, and sendRoomMessageDirected: every error code (missing_scope_path, unauthorized, malformed_params), the replyTo/ streaming-behavior optional spreads on both room and dm-path sends, the dm-vs-room history branch, room.read's readBy dedup and dm/room event-shape distinction, and room.members' dm-participant-vs-Room- member mapping. room-protocol-admission.test.ts covers sendRoomRequestToMember/flushPendingRoomRequests (including the MAX_QUEUED_DELIVERIES_PER_AGENT oldest-first bound), handleRoomJoin/ admitRoomJoin (not_owner/not_participant/dm-auto-approve branches, the held-open accept/reject continuation, minting and persisting the granted token), handleRoomInvite (the deliberately-ungated verb, its embedded-token verification, and the room-state/inviter-agent extension fallbacks), and handleRoomLeave (member-vs-invited-decline branches, revocation, and the member_left/invite_declined event distinction).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…rage Verified against a fresh mutation run: streamingBehavior's optional inclusion was only tested for owner-named room sends, not the dm-path branch that constructs a separate DmMessage object; handleRoomMembers' token-verification-failure branch had no test at all, only the no-token-presented case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #111
Test plan
pnpm typecheckpnpm lintpnpm test(67 files, 578 tests, full suite green)