From ad512bde11943a9a21094f48a63d4e47264c71b6 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Fri, 16 Oct 2026 01:41:41 -0400 Subject: [PATCH] test(minigames): cover bomperator input seq guard and snapshot echo Two registry specs: stale/out-of-order seq posts are ignored while the newest intent wins, and each seat's last applied seq is echoed in the snapshot. --- tests/int/bomperator-registry.int.spec.ts | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/int/bomperator-registry.int.spec.ts b/tests/int/bomperator-registry.int.spec.ts index 84fb6056..17d916d2 100644 --- a/tests/int/bomperator-registry.int.spec.ts +++ b/tests/int/bomperator-registry.int.spec.ts @@ -116,6 +116,42 @@ describe("bomperator registry: input + ticking", () => { }); }); +describe("bomperator registry: input sequencing", () => { + it("applies only the newest seq and ignores stale out-of-order posts", () => { + const matchId = createMatch(9751, "Host"); + joinMatch(matchId, 9752, "Guest"); + startMatch(matchId, 9751); + toBattle(matchId); + + submitInput(matchId, 9751, { dir: "right", seq: 1 }); + advanceForTests(matchId, 6); + const right = getSnapshotFor(matchId, 9751); + const rightX = right.players[right.yourSeat!].x; + expect(rightX).toBeGreaterThan(1.5); + + // A stale echo of an older intent must never resurrect it. + submitInput(matchId, 9751, { dir: "left", seq: 3 }); + submitInput(matchId, 9751, { dir: "right", seq: 2 }); + advanceForTests(matchId, 6); + const after = getSnapshotFor(matchId, 9751); + expect(after.players[after.yourSeat!].x).toBeLessThan(rightX); + }); + + it("echoes each seat's last applied input seq in the snapshot", () => { + const matchId = createMatch(9761, "Host"); + joinMatch(matchId, 9762, "Guest"); + startMatch(matchId, 9761); + toBattle(matchId); + + expect(getSnapshotFor(matchId, 9761).players[0].lastInputSeq).toBe(0); + submitInput(matchId, 9761, { dir: "down", seq: 5 }); + submitInput(matchId, 9761, { dir: "up", seq: 4 }); // stale: ignored + const view = getSnapshotFor(matchId, 9761); + expect(view.players[0].lastInputSeq).toBe(5); + expect(view.players[1].lastInputSeq).toBe(0); + }); +}); + describe("bomperator registry: disconnect and dissolve", () => { it("holds a seat on leave and restores it on rejoin", () => { const matchId = createMatch(9801, "Host");