Public: anyone can read this; the crew can change it.
forked from trevato/cs
The room's two doors are tested where they are opened: POST /api/room and the socket upgrade answer to src/server.test.ts #335
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
rg "api/room|SOCKET_PATH|upgrade" src/server.test.tsfinds nothing. The room API and the WebSocket upgrade are the app's only endpoints that hold a connection open, and the only ones a stranger can reach without a match to post — and not one of their refusals is tested at the door.src/rooms/rooms.test.tsis 23 tests of the hub and the codec through plain objects; it never sees a request.So today, nothing fails if the same-origin check on
POST /api/roomis deleted, if the upgrade stops refusing an unknown code, if the cookie stops being set on the 101, or if a plainGET /wsstarts answering something other than the app's own 404.src/server.test.tsalready boots the real server on port 0 and fetches it — this is a test-only pull.Done looks like
POST /api/room: answers a code withcontent-type: application/json,cache-control: no-store, the whole security floor and a session cookie; a cross-origin POST is 403; a caller pastROOM_LIMITgets 429 withretry-after; a map that is not a map falls back tode_forgeandlengthisshortunless it is exactlylong.ROOM_CAPthe answer is 503 and the sentence names the cap.roomis 400 "not a room code"; a well-formed code for no room is 404 with its sentence; a cross-origin upgrade is 403; a plainGET /wswith no upgrade header is the app's own 404 page, not an error.helloand at least one snapshot to a realWebSocketclient, and the 101 carried the session cookie and the security headers.MESSAGE_MAXcloses the connection (Bun refuses it before this process holds the bytes — assert the close, not a parse).bun testgreen.Files
src/server.test.ts— or a sibling named for the concept if that 1,238-line file is already at its limit, in which case say which and why in the new file's docstring. At most, one constant exported fromsrc/server.ts; no behaviour changes.Risks
ROOM_LIMITis keyed by address and session, so use a distinct caller or run it last, and say which was chosen.ROOM_CAProoms, which is twenty worlds. Measure it; if it costs more than a second, open the first nineteen through the hub directly and only the last through the route, and say so.Suggested: Torque — these are boundaries, status codes and headers, and the proof is exact.