mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-20 15:48:33 +02:00
fix: gate direct (entry-fee) payouts behind DIRECT_PAYOUTS_ENABLED
completeGame only gated PAID_CREDITS payouts (on creditsPayoutEnabled); a PAID_SINGLE win paid out unconditionally, so DIRECT_PAYOUTS_ENABLED=false did NOT actually stop direct payouts — a no-payout instance (mainnet legitimacy) would still send crypto on an entry-fee win. Caught during deploy verification. - Add this.directPayoutEnabled (from DIRECT_PAYOUTS_ENABLED env / direct rule enabled in the config snapshot), mirroring creditsPayoutEnabled. - completeGame now gates the PAID_SINGLE payout on directPayoutEnabled. - The derived directPayoutsEnabled flags (getGameModeInfo / effective mode) and /api/game-modes PAID_SINGLE.payoutMultiplier now respect it (show 0 when off) instead of inferring from multipliers > 0. Adds a regression test: a PAID_SINGLE win with directPayoutEnabled=false queues no payout. Full suite: 22 suites / 159 tests.
This commit is contained in:
@@ -89,4 +89,21 @@ describe('Payout uses the snapshot recorded at game start', () => {
|
||||
|
||||
expect(result.payout.amount).toBe(200000000000); // live 2x
|
||||
});
|
||||
|
||||
test('no payout for a PAID_SINGLE win when direct payouts are disabled (no-payout instance)', async () => {
|
||||
const { gmm, db } = buildGmm();
|
||||
gmm.directPayoutEnabled = false; // e.g. mainnet legitimacy: sell entry, never pay out
|
||||
|
||||
db.query
|
||||
.mockResolvedValueOnce({ rows: [{ id: 1, game_mode: 'PAID_SINGLE', payout_address: 'wow1addr' }] }) // game record
|
||||
.mockResolvedValue({ rows: [] }); // completion UPDATE + anything else
|
||||
|
||||
const result = await gmm.completeGame('socket1', 'game123', true, true, { moves: 10 });
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.payout == null || result.payout === undefined).toBe(true); // no payout queued
|
||||
// No payout INSERT happened.
|
||||
const insertedPayout = db.query.mock.calls.find(c => /INSERT INTO payouts/i.test(c[0]));
|
||||
expect(insertedPayout).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user