feat(diagnostics): correlate movement acknowledgements with painted views

This commit is contained in:
2026-09-09 22:12:12 +03:00
parent 3827ba7ec7
commit 37704028c5
5 changed files with 389 additions and 14 deletions
+19
View File
@@ -43,6 +43,25 @@ test("joystick repeat interval is monotonic and remains slower than cooldown", (
assert.ok(player.JOYSTICK_FAST_REPEAT_MS > 150);
});
test("latency correlation is bounded and only completes matching authoritative views", () => {
let clock = 0;
const tracker = new player.LatencyTracker(() => clock);
tracker.sent("move-1");
clock = 12;
tracker.acknowledged("move-1", 41);
clock = 16;
tracker.painted(40);
assert.equal(tracker.snapshot().length, 0);
clock = 24;
tracker.painted(41);
assert.deepEqual(tracker.snapshot(), [{requestId: "move-1", commandToAckMs: 12,
commandToPaintMs: 24, ackToPaintMs: 12}]);
for (let index = 0; index < player.LATENCY_SAMPLE_LIMIT + 4; index++) {
tracker.sent(`move-${index + 2}`);
}
assert.ok(tracker.pending.size <= player.LATENCY_SAMPLE_LIMIT);
});
test("player map cells enlarge small projections without exceeding a readable bound", () => {
const sevenBySeven = player.playerCellSize(396, 730, 7, 7);
const fourByFour = player.playerCellSize(396, 730, 4, 4);