feat: v0.7.0 — server-authoritative sim engine: tick-on-read clock (time-scale + pause via POST /api/sim), contract expiry + market spawn, analytic plane movement/finalization
This commit is contained in:
+10
-3
@@ -65,9 +65,16 @@ test('state survives a container restart (sim clock + account persisted)', async
|
||||
expect(after).toBeDefined();
|
||||
const a = after!;
|
||||
|
||||
// The sim clock and account must be byte-identical — the DB file on the
|
||||
// volume is loaded, not re-seeded (PLAN.md: "sim clock persisted across sessions").
|
||||
expect(a.simState.clockMs).toBe(before.simState.clockMs);
|
||||
// The DB file on the volume must be loaded, not re-seeded (PLAN.md: "sim clock
|
||||
// persisted across sessions"): account and entity ids are byte-identical.
|
||||
// v0.7.0 tick-on-read caveat: every GET advances the clock by at most one
|
||||
// clamped tick (MAX_TICK_ELAPSED_MS × timeScale, see lib/sim/engine.ts), so the
|
||||
// post-restart clock may be ahead — but never by more than that bound.
|
||||
expect(a.simState.clockMs).toBeGreaterThanOrEqual(before.simState.clockMs);
|
||||
const MAX_TICK_ELAPSED_MS = 2_000; // must match lib/sim/engine.ts
|
||||
expect(a.simState.clockMs - before.simState.clockMs).toBeLessThanOrEqual(
|
||||
MAX_TICK_ELAPSED_MS * a.simState.timeScale,
|
||||
);
|
||||
expect(a.account.cash).toBe(before.account.cash);
|
||||
expect(a.account.reputation).toBe(before.account.reputation);
|
||||
expect(a.planes.map((p) => p.id).sort()).toEqual(before.planes.map((p) => p.id).sort());
|
||||
|
||||
Reference in New Issue
Block a user