Skip to content

Commit 650b4a0

Browse files
grrowlclaude
andcommitted
test(server): make oversized-frame test falsifiable (reviewer fix)
Test 4 ("oversized frame is dropped") previously only filtered for `rejected` frames referencing txId "wh-big1", which passes even when the guard is disabled (the DO processes the payload and emits `committed`, not `rejected`). Two stronger assertions added: - `expect(droppedFrames).toHaveLength(0)` — this socket has no subscriptions so ANY frame arriving signals the guard failed; a `committed` frame now causes the test to fail correctly. - `runInDurableObject` DB check: `SELECT COUNT(*) FROM messages WHERE id='big'` must be 0 — the strongest signal the write was never applied. Verified falsifiability: temporarily setting `if (false && byteLen > this.maxFrameBytes)` causes the test to fail with "expected [{ t: 'committed' }] to have length 0"; restoring the guard makes it pass. Full suite: 183 tests, 43 files, all pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5bf911c commit 650b4a0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

tests/wire-hardening.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,18 @@ describe("wire-hardening (ADR-0012)", () => {
215215
}
216216

217217
// Collect for a short window — no reply expected (frame was dropped).
218+
// This socket has no subscriptions, so the window must be entirely empty:
219+
// any frame at all (committed, rejected, or delta) would mean the guard
220+
// failed and the oversized payload reached dispatch.
218221
const droppedFrames = await collectFor(ws, 300)
219-
const anyReply = droppedFrames.filter((f) => {
220-
const r = f as Extract<ServerFrame, { t: "rejected" }>
221-
return f.t === "rejected" && (r as typeof r).txId === "wh-big1"
222+
expect(droppedFrames).toHaveLength(0)
223+
224+
// Server-side confirmation: the row must not have been inserted.
225+
const stub = env.SYNC_DO.get(env.SYNC_DO.idFromName("wh-oversize"))
226+
const rows = await runInDurableObject(stub, (_i, s) => {
227+
return Array.from(s.storage.sql.exec("SELECT COUNT(*) as cnt FROM messages WHERE id='big'"))
222228
})
223-
expect(anyReply).toHaveLength(0)
229+
expect((rows[0] as { cnt: number }).cnt).toBe(0)
224230

225231
// Socket survives: a normal mut succeeds.
226232
send(ws, {

0 commit comments

Comments
 (0)