rook/val Public Public: anyone can read this; nobody can change it.
forked from benjivers/val
workbenchthis machine
The prediction bound has to read the same speed table the client does
The deploy gate failed on a bound that assumed a walking seat: the drawn body led the server by 84 units where the test allowed 72. The code was right. 0.25s (predict.js LEAD_MAX) x 250 (RUN) x 1.35 (haste) = 84.4 — the seat was hasted, the cap held exactly, and the test was measuring the match's mood. It now reads moveSpeed(seat) and LEAD_MAX from the modules the client itself uses, so it asserts the rule rather than a number that happened to be true on a quiet machine.
1 file
changed +9
−1
src/client.test.ts +9 −1
| @@ -357,7 +357,15 @@ test("the bundled client connects, paints the HUD and draws a frame", async () = | ||
| 357 | 357 | const lead = (drawnAt.x / scale - seat.x) * clear[1] + (drawnAt.y / scale - seat.y) * clear[2]; |
| 358 | 358 | const sideways = (drawnAt.x / scale - seat.x) * clear[2] - (drawnAt.y / scale - seat.y) * clear[1]; |
| 359 | 359 | expect(lead).toBeGreaterThan(30); |
| 360 | expect(lead).toBeLessThan(0.25 * 250 + 10); | |
| 360 | // A quarter second of THIS seat's movement, not of a walking one: haste | |
| 361 | // multiplies the speed by 1.35, and a seat that happened to be hasted led | |
| 362 | // by 84 where a bound written around the base 250 expected 72. The cap is | |
| 363 | // in time (predict.js LEAD_MAX), so the bound has to be read off the same | |
| 364 | // speed table the client used, or it measures the match's mood instead of | |
| 365 | // the rule. | |
| 366 | const { moveSpeed } = await import("./glide.ts"); | |
| 367 | const { LEAD_MAX } = await import("../static/predict.js"); | |
| 368 | expect(lead).toBeLessThan(LEAD_MAX * moveSpeed(seat) + 10); | |
| 361 | 369 | expect(Math.abs(sideways)).toBeLessThan(6); |
| 362 | 370 | // Nothing on the server moved: this is a drawing, and the match is still |
| 363 | 371 | // the only thing that says where anybody is. |