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.
This commit is contained in:
parent
7935e857af
commit
ad512bde11
1 changed files with 36 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue