mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-17 14:21:25 +02:00
A browser-based roguelike synchronized with crypto block timing. A run is a race against the next block: reach the exit before the block lands, or the house wins. The same codebase runs the solo dungeon, the social Tavern, and operator-selected PvP and race rulesets, with separate free and paid leaderboards. Self-hostable under the MIT License. See README.md to run it, docs/ARCHITECTURE.md for the design, and docs/DEPLOY.md to operate an instance.
76 lines
2.9 KiB
JavaScript
76 lines
2.9 KiB
JavaScript
const { isSmirkEnabled } = require('../src/auth/smirkPolicy');
|
|
const GameModeManager = require('../src/game/gameModeManager');
|
|
const ClientSocketHandlers = require('../html/js/network/socketHandlers');
|
|
|
|
function gameModeInfoFixture() {
|
|
const manager = Object.create(GameModeManager.prototype);
|
|
Object.assign(manager, {
|
|
creditsPayoutBaseValue: 0,
|
|
cryptoType: 'WOW',
|
|
network: 'mainnet',
|
|
isTestNetwork: false,
|
|
configSnapshot: { modes: { credits: { packages: [] } }, earlyEntry: {} },
|
|
gameMode: 'FREE',
|
|
freePlayEnabled: true,
|
|
singleGamePrice: 0,
|
|
creditsPackagePrice: 0,
|
|
creditsPerGameCost: 1,
|
|
paymentsEnabled: false,
|
|
directModeEnabled: false,
|
|
creditsModeEnabled: false,
|
|
payoutsEnabled: false,
|
|
directPayoutMultipliers: {},
|
|
creditPayoutMultipliers: {},
|
|
formatAtomic: () => '0',
|
|
formatAtomicHuman: () => '0',
|
|
getCosmeticProducts: () => [],
|
|
isPayoutEnabledForMode: () => false,
|
|
_getMatchEconomies: () => [],
|
|
_getMatchRulesetInfo: () => ({})
|
|
});
|
|
return manager.getGameModeInfo();
|
|
}
|
|
|
|
describe('Smirk explicit opt-in policy', () => {
|
|
const original = {};
|
|
|
|
beforeEach(() => {
|
|
for (const key of ['SMIRK_ENABLED', 'MONERO_NETWORK']) original[key] = process.env[key];
|
|
});
|
|
|
|
afterEach(() => {
|
|
for (const key of Object.keys(original)) {
|
|
if (original[key] === undefined) delete process.env[key];
|
|
else process.env[key] = original[key];
|
|
}
|
|
});
|
|
|
|
test('server policy is off for missing/truthy-ish values and every test network', () => {
|
|
expect(isSmirkEnabled({ MONERO_NETWORK: 'mainnet' })).toBe(false);
|
|
expect(isSmirkEnabled({ SMIRK_ENABLED: 'TRUE', MONERO_NETWORK: 'mainnet' })).toBe(false);
|
|
expect(isSmirkEnabled({ SMIRK_ENABLED: '1', MONERO_NETWORK: 'mainnet' })).toBe(false);
|
|
expect(isSmirkEnabled({ SMIRK_ENABLED: 'true', MONERO_NETWORK: 'stagenet' })).toBe(false);
|
|
expect(isSmirkEnabled({ SMIRK_ENABLED: 'true', MONERO_NETWORK: 'testnet' })).toBe(false);
|
|
expect(isSmirkEnabled({ SMIRK_ENABLED: 'true', MONERO_NETWORK: 'mainnet' })).toBe(true);
|
|
});
|
|
|
|
test('game-mode payload defaults Smirk off and advertises it only for exact mainnet opt-in', () => {
|
|
delete process.env.SMIRK_ENABLED;
|
|
process.env.MONERO_NETWORK = 'mainnet';
|
|
expect(gameModeInfoFixture().smirkEnabled).toBe(false);
|
|
|
|
process.env.SMIRK_ENABLED = 'true';
|
|
expect(gameModeInfoFixture().smirkEnabled).toBe(true);
|
|
|
|
process.env.MONERO_NETWORK = 'stagenet';
|
|
expect(gameModeInfoFixture().smirkEnabled).toBe(false);
|
|
});
|
|
|
|
test('browser gate accepts only the explicit boolean true sent by the server', () => {
|
|
expect(ClientSocketHandlers._isSmirkExplicitlyEnabled({})).toBe(false);
|
|
expect(ClientSocketHandlers._isSmirkExplicitlyEnabled({ smirkEnabled: 'true' })).toBe(false);
|
|
expect(ClientSocketHandlers._isSmirkExplicitlyEnabled({ smirkEnabled: false })).toBe(false);
|
|
expect(ClientSocketHandlers._isSmirkExplicitlyEnabled({ smirkEnabled: true })).toBe(true);
|
|
});
|
|
});
|