diff --git a/tests/game-core.test.ts b/tests/game-core.test.ts index 30b4d60..05a2c81 100644 --- a/tests/game-core.test.ts +++ b/tests/game-core.test.ts @@ -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); }); +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', () => { let state = createMatch(DEFAULT_RULESET, [flatDeck(1, 'a'), flatDeck(1, 'b')], 3); const first = state.players[0].hand[0].cardId;