mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-17 22:31:26 +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.
94 lines
3.1 KiB
JavaScript
94 lines
3.1 KiB
JavaScript
const { isPayoutProcessingEnabled, isWalletRequired } = require('../src/config/runtimePolicy');
|
|
|
|
const baseConfig = () => ({
|
|
payouts: {
|
|
enabled: true,
|
|
rules: {
|
|
direct: { enabled: true },
|
|
credits: { enabled: true }
|
|
}
|
|
},
|
|
modes: {
|
|
direct: { enabled: true },
|
|
credits: { enabled: true }
|
|
}
|
|
});
|
|
|
|
const baseManager = () => ({
|
|
payoutsEnabled: true,
|
|
directPayoutEnabled: true,
|
|
creditsPayoutEnabled: true
|
|
});
|
|
|
|
describe('runtime payout worker policy', () => {
|
|
test('master config switch suppresses every per-mode payout worker', () => {
|
|
const config = baseConfig();
|
|
config.payouts.enabled = false;
|
|
|
|
expect(isPayoutProcessingEnabled(config, baseManager())).toBe(false);
|
|
});
|
|
|
|
test('manager emergency switch also suppresses workers after hot reload', () => {
|
|
const manager = baseManager();
|
|
manager.payoutsEnabled = false;
|
|
|
|
expect(isPayoutProcessingEnabled(baseConfig(), manager)).toBe(false);
|
|
});
|
|
|
|
test('disabled modes cannot accidentally activate a worker through stale payout flags', () => {
|
|
const config = baseConfig();
|
|
config.modes.direct.enabled = false;
|
|
config.modes.credits.enabled = false;
|
|
|
|
expect(isPayoutProcessingEnabled(config, baseManager())).toBe(false);
|
|
});
|
|
|
|
test('one explicitly active policy is enough to process its queued payouts', () => {
|
|
const config = baseConfig();
|
|
config.modes.direct.enabled = false;
|
|
const manager = baseManager();
|
|
manager.directPayoutEnabled = false;
|
|
|
|
expect(isPayoutProcessingEnabled(config, manager)).toBe(true);
|
|
});
|
|
|
|
test('accepted durable liabilities keep the generic worker alive after admission is disabled', () => {
|
|
const config = baseConfig();
|
|
config.modes.direct.enabled = false;
|
|
config.modes.credits.enabled = false;
|
|
const manager = baseManager();
|
|
manager.directPayoutEnabled = false;
|
|
manager.creditsPayoutEnabled = false;
|
|
|
|
expect(isPayoutProcessingEnabled(config, manager)).toBe(false);
|
|
expect(isPayoutProcessingEnabled(config, manager, {
|
|
settleAcceptedLiabilities: true
|
|
})).toBe(true);
|
|
|
|
config.payouts.enabled = false;
|
|
expect(isPayoutProcessingEnabled(config, manager, {
|
|
settleAcceptedLiabilities: true
|
|
})).toBe(false);
|
|
});
|
|
|
|
test('wallet remains mandatory for payout-only accepted-liability settlement', () => {
|
|
const config = baseConfig();
|
|
config.paymentsEnabled = false;
|
|
config.modes.direct.enabled = false;
|
|
config.modes.credits.enabled = false;
|
|
const manager = baseManager();
|
|
manager.directPayoutEnabled = false;
|
|
manager.creditsPayoutEnabled = false;
|
|
|
|
expect(isWalletRequired(config, manager)).toBe(false);
|
|
expect(isWalletRequired(config, manager, {
|
|
settleAcceptedLiabilities: true
|
|
})).toBe(true);
|
|
|
|
config.payouts.enabled = false;
|
|
expect(isWalletRequired(config, manager, {
|
|
settleAcceptedLiabilities: true
|
|
})).toBe(false);
|
|
});
|
|
});
|