Engine tests: viewFor never leaks opponent hand, deck order, seed or RNG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 23:17:04 -05:00
co-authored by Claude Opus 5.5
parent e0ac157ee1
commit c938407d36
+12
View File
@@ -99,6 +99,18 @@ test('queued plays are hidden until reveal; undo refunds; committed seats get no
assert.throws(() => applyAction(state, { type: 'play', player: 0, cardId: play.cardId, lane: 0 }), IllegalActionError); assert.throws(() => applyAction(state, { type: 'play', player: 0, cardId: play.cardId, lane: 0 }), IllegalActionError);
}); });
test('viewFor never leaks the opponent hand, deck order, queue, seed or RNG state', () => {
let state = createMatch(DEFAULT_RULESET, [flatDeck(1, 'mine'), flatDeck(1, 'opp')], 'leak-seed');
const play = legalActions(state, 1).find(x => x.type === 'play')!;
state = applyAction(state, play);
const view = viewFor(state, 0);
const json = JSON.stringify(view);
for (const key of ['"seed"', '"rng"', '"deck"', '"log"', '"actions"']) assert.equal(json.includes(key), false, key);
for (const c of [...state.players[1].hand, ...state.players[1].deck, ...state.players[0].deck])
assert.equal(json.includes(`"${c.cardId}"`), false, c.cardId);
assert.deepEqual(view.hand.map(c => c.cardId), state.players[0].hand.map(c => c.cardId));
});
test('energy: energyByTurn + carry (max 1) of unspent energy', () => { test('energy: energyByTurn + carry (max 1) of unspent energy', () => {
let state = createMatch(DEFAULT_RULESET, [flatDeck(1, 'a'), flatDeck(1, 'b')], 3); let state = createMatch(DEFAULT_RULESET, [flatDeck(1, 'a'), flatDeck(1, 'b')], 3);
const first = state.players[0].hand[0].cardId; const first = state.players[0].hand[0].cardId;