Operations now report the SQLite database size and page count, read through PRAGMA page_count/page_size in the same authority-checked batch as the lifecycle counters with non-numeric values clamped to zero; the page renders both and states that free disk space is still unknown. replaceMoritaniAssassinationTraitors draws the first distinct physical Traitor Card from the reserve instead of the reserve's first entry, because the face-up set-aside card can still sit in that list: re-drawing it produced a receipt whose replacement equalled the revealed card, which the assassination integrity check rejects mid-Mentat. With no distinct card left the step is blocked with an explicit reason instead of committing an invalid receipt. Four tests were made reproducible after measuring their real failure rates, because a suite that fails for random reasons cannot act as a checkpoint gate: the Discovery typed Spice Blow test now removes other cards for the same territory so one blow deposits the printed amount (0/20 after, ~20% before); the Discovery E2 skills deal is pinned with the new shared tests/deterministic-random.ts helper so a Lasgun-shield explosion cannot pre-empt its skill consumer (0/12 after, ~20% before); the Ecaz Occupy Ix/CHOAM policy check accepts any legal continuation and still asserts the phase it reaches (0/30 after, ~10% before); and the mixed-E3 Moritani Cunning test keeps the random storm off red_chasm's single sector (0/25 after, ~20% before). Offline suite 7,801/7,801 with typecheck and lint clean. No game, seat, saved state or deployment changes.
23 lines
989 B
TypeScript
23 lines
989 B
TypeScript
import type { TestContext } from 'node:test';
|
|
|
|
/** A deterministic byte source for `crypto.getRandomValues`.
|
|
*
|
|
* Tests that build genuine games otherwise inherit the process's real entropy:
|
|
* a random storm can place a fixture's chosen sector in the storm, and a random
|
|
* deal can seal a Lasgun-shield explosion or empty the Traitor Deck reserve.
|
|
* Pinning the source makes those tests reproducible without weakening what they
|
|
* assert. `t.mock` restores the original at the end of the test. */
|
|
export function pinDeterministicRandom(t: TestContext, seed = 0x2f6e2b1): void {
|
|
let state = seed;
|
|
t.mock.method(crypto, 'getRandomValues', <T extends ArrayBufferView | null>(array: T): T => {
|
|
if (array) {
|
|
const bytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
for (let i = 0; i < bytes.length; i++) {
|
|
state = (state * 1103515245 + 12345) & 0x7fffffff;
|
|
bytes[i] = (state >>> 16) & 0xff;
|
|
}
|
|
}
|
|
return array;
|
|
});
|
|
}
|