mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-12-04 12:54:08 +01:00
fix: enforce operated product boundaries
This commit is contained in:
@@ -93,6 +93,7 @@ describe('commerce disclosure and paid-action policy', () => {
|
||||
expect(disclosure.operatedProduct.scopeNotice).toContain('single-player 2×/3× outcomes are test gambling mechanics');
|
||||
expect(disclosure.operatedProduct.noRealValueNotice).toContain('NO REAL VALUE');
|
||||
expect(disclosure.operatedProduct.commerceSummary).toContain('never send mainnet XMR');
|
||||
expect(disclosure.service.cryptoMatchPayoutsEnabled).toBe(false);
|
||||
expect(disclosure.software).toEqual(expect.objectContaining({
|
||||
license: 'MIT',
|
||||
publisherName: 'Such Software'
|
||||
|
||||
@@ -197,6 +197,9 @@ describe('EnvironmentValidator production launch gate', () => {
|
||||
DIRECT_PAYOUTS_ENABLED: 'false',
|
||||
CREDITS_PAYOUTS_ENABLED: 'false',
|
||||
ALLOW_MAINNET_PAYOUTS: 'false',
|
||||
SOLO_ENABLED: 'true',
|
||||
TAVERN_ENABLED: 'true',
|
||||
MATCH_ENABLED: 'true',
|
||||
MATCH_CRYPTO_RACE_ENABLED: 'false',
|
||||
MATCH_PAYOUTS_ENABLED: 'false'
|
||||
});
|
||||
@@ -241,6 +244,9 @@ describe('EnvironmentValidator production launch gate', () => {
|
||||
CREDITS_PAYOUT_ESCAPE: '2.0',
|
||||
CREDITS_PAYOUT_TREASURE: '3.0',
|
||||
ALLOW_MAINNET_PAYOUTS: 'false',
|
||||
SOLO_ENABLED: 'true',
|
||||
TAVERN_ENABLED: 'true',
|
||||
MATCH_ENABLED: 'true',
|
||||
MATCH_CRYPTO_RACE_ENABLED: 'false',
|
||||
MATCH_PAYOUTS_ENABLED: 'false'
|
||||
});
|
||||
@@ -341,6 +347,9 @@ describe('EnvironmentValidator production launch gate', () => {
|
||||
CREDITS_PAYOUT_ESCAPE: '2',
|
||||
CREDITS_PAYOUT_TREASURE: '3',
|
||||
ALLOW_MAINNET_PAYOUTS: 'true',
|
||||
SOLO_ENABLED: 'false',
|
||||
TAVERN_ENABLED: 'false',
|
||||
MATCH_ENABLED: 'false',
|
||||
MATCH_CRYPTO_RACE_ENABLED: 'true',
|
||||
MATCH_PAYOUTS_ENABLED: 'true'
|
||||
});
|
||||
@@ -357,6 +366,9 @@ describe('EnvironmentValidator production launch gate', () => {
|
||||
expect.stringContaining('requires OPERATOR_CONTACT_URL=mailto:apps@such.software'),
|
||||
expect.stringContaining('requires MONERO_NETWORK=stagenet'),
|
||||
expect.stringContaining('requires DIRECT_PAYOUT_ESCAPE=2'),
|
||||
expect.stringContaining('requires SOLO_ENABLED=true'),
|
||||
expect.stringContaining('requires TAVERN_ENABLED=true'),
|
||||
expect.stringContaining('requires MATCH_ENABLED=true'),
|
||||
expect.stringContaining('requires MATCH_CRYPTO_RACE_ENABLED=false'),
|
||||
expect.stringContaining('requires MATCH_PAYOUTS_ENABLED=false'),
|
||||
expect.stringContaining('requires ALLOW_MAINNET_PAYOUTS=false')
|
||||
|
||||
@@ -214,6 +214,20 @@ describe('GameModeManager', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('game mode info publishes only a recognized operated product profile id', () => {
|
||||
const old = process.env.OPERATED_PRODUCT_PROFILE;
|
||||
try {
|
||||
process.env.OPERATED_PRODUCT_PROFILE = 'such-play-wow-prestige';
|
||||
expect(gmm.getGameModeInfo().operatedProductProfileId)
|
||||
.toBe('such-play-wow-prestige');
|
||||
process.env.OPERATED_PRODUCT_PROFILE = 'unreviewed-profile';
|
||||
expect(gmm.getGameModeInfo().operatedProductProfileId).toBeNull();
|
||||
} finally {
|
||||
if (old === undefined) delete process.env.OPERATED_PRODUCT_PROFILE;
|
||||
else process.env.OPERATED_PRODUCT_PROFILE = old;
|
||||
}
|
||||
});
|
||||
|
||||
test('crypto race economy is hidden when the payout master switch is off', () => {
|
||||
const keys = [
|
||||
'MATCH_ENABLED', 'MATCH_CRYPTO_RACE_ENABLED', 'MATCH_PAYOUTS_ENABLED',
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
'use strict';
|
||||
|
||||
const createErrorMiddleware = require('../src/middleware/errorHandler');
|
||||
const { createLeaderboardHandler } = require('../src/routes/leaderboard');
|
||||
|
||||
const SOURCE_MATCH = '11111111-1111-4111-8111-111111111111';
|
||||
const COMPLETED_AT = '2026-07-20T12:00:00.000Z';
|
||||
|
||||
function fixtureDatabase() {
|
||||
const users = new Map([
|
||||
[1, { id: 1, display_name: 'CreditSolo', payout_address: null }],
|
||||
[2, { id: 2, display_name: 'LegacyDirect', payout_address: null }],
|
||||
[3, { id: 3, display_name: 'MatchOutcome', payout_address: null }],
|
||||
[4, { id: 4, display_name: 'MatchLink', payout_address: null }],
|
||||
[5, { id: 5, display_name: 'FreeSolo', payout_address: null }],
|
||||
[6, { id: 6, display_name: 'FreeMatch', payout_address: null }]
|
||||
]);
|
||||
const games = [
|
||||
{
|
||||
user_id: 1, game_mode: 'PAID_CREDITS', status: 'won', outcome: 'escaped',
|
||||
score: 500, dungeon_seed: 'solo-credit', completed_at: COMPLETED_AT
|
||||
},
|
||||
{
|
||||
user_id: 2, game_mode: 'PAID_SINGLE', status: 'lost', outcome: 'caught_by_monster',
|
||||
score: 450, dungeon_seed: 'legacy-direct', completed_at: COMPLETED_AT
|
||||
},
|
||||
{
|
||||
user_id: 3, game_mode: 'PAID_CREDITS', status: 'won', outcome: 'match_winner',
|
||||
score: 990, dungeon_seed: 'legacy-match-without-link', completed_at: COMPLETED_AT
|
||||
},
|
||||
{
|
||||
user_id: 4, game_mode: 'PAID_CREDITS', status: 'won', outcome: 'escaped',
|
||||
score: 980, dungeon_seed: SOURCE_MATCH, completed_at: COMPLETED_AT
|
||||
},
|
||||
{
|
||||
user_id: 5, game_mode: 'FREE', status: 'lost', outcome: 'caught_by_monster',
|
||||
score: 300, dungeon_seed: 'solo-free', completed_at: COMPLETED_AT
|
||||
},
|
||||
{
|
||||
user_id: 6, game_mode: 'FREE', status: 'won', outcome: 'match_winner',
|
||||
score: 350, dungeon_seed: SOURCE_MATCH, completed_at: COMPLETED_AT
|
||||
}
|
||||
];
|
||||
const calls = [];
|
||||
|
||||
return {
|
||||
calls,
|
||||
async query(sql, params) {
|
||||
calls.push({ sql, params });
|
||||
const [cutoff, gameModes, excludeMatchGenerated, limit] = params;
|
||||
const rows = games.filter(game => {
|
||||
if (!gameModes.includes(game.game_mode)) return false;
|
||||
if (!['won', 'lost'].includes(game.status) || game.score <= 0) return false;
|
||||
if (cutoff && new Date(game.completed_at) <= cutoff) return false;
|
||||
if (excludeMatchGenerated
|
||||
&& (String(game.outcome || '').startsWith('match_')
|
||||
|| game.dungeon_seed === SOURCE_MATCH)) return false;
|
||||
return true;
|
||||
});
|
||||
const aggregate = new Map();
|
||||
for (const game of rows) {
|
||||
const user = users.get(game.user_id);
|
||||
const current = aggregate.get(user.id) || {
|
||||
id: user.id,
|
||||
name: user.display_name || `Anon#${user.id}`,
|
||||
best_score: 0,
|
||||
wins: 0,
|
||||
games_played: 0
|
||||
};
|
||||
current.best_score = Math.max(current.best_score, game.score);
|
||||
current.wins += game.status === 'won' ? 1 : 0;
|
||||
current.games_played += 1;
|
||||
aggregate.set(user.id, current);
|
||||
}
|
||||
return {
|
||||
rows: Array.from(aggregate.values())
|
||||
.sort((a, b) => b.best_score - a.best_score)
|
||||
.slice(0, limit)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function invokeLeaderboardRoute(profileId, query = {}) {
|
||||
const db = fixtureDatabase();
|
||||
const handler = createLeaderboardHandler({
|
||||
db,
|
||||
getOperatedProductProfileId: () => profileId,
|
||||
now: () => new Date('2026-07-21T12:00:00.000Z')
|
||||
});
|
||||
const req = { query, path: '/api/leaderboard', method: 'GET' };
|
||||
const response = { status: 200, body: null };
|
||||
const res = {
|
||||
status(status) {
|
||||
response.status = status;
|
||||
return this;
|
||||
},
|
||||
json(body) {
|
||||
response.body = body;
|
||||
return this;
|
||||
}
|
||||
};
|
||||
try {
|
||||
await handler(req, res);
|
||||
} catch (error) {
|
||||
createErrorMiddleware({ logger: { error: jest.fn() } })(error, req, res, () => {});
|
||||
}
|
||||
return { response, db };
|
||||
}
|
||||
|
||||
describe('GET /api/leaderboard operated-product integrity', () => {
|
||||
test('Wownero Champions includes credit-entry solo only', async () => {
|
||||
const { response, db } = await invokeLeaderboardRoute('such-play-wow-prestige', {
|
||||
board: 'champions',
|
||||
period: 'all'
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.board).toBe('champions');
|
||||
expect(response.body.leaderboard.map(row => row.name)).toEqual(['CreditSolo']);
|
||||
expect(db.calls[0].params.slice(1, 3)).toEqual([['PAID_CREDITS'], true]);
|
||||
});
|
||||
|
||||
test('Monerogue Champions includes direct and credit solo, never match-generated rows', async () => {
|
||||
const { response, db } = await invokeLeaderboardRoute('such-monerogue-stagenet', {
|
||||
board: 'champions',
|
||||
period: 'all'
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.leaderboard.map(row => row.name))
|
||||
.toEqual(['CreditSolo', 'LegacyDirect']);
|
||||
expect(db.calls[0].params.slice(1, 3))
|
||||
.toEqual([['PAID_SINGLE', 'PAID_CREDITS'], true]);
|
||||
});
|
||||
|
||||
test('independent deployments retain the generic opt-in crypto-match mapping', async () => {
|
||||
const { response, db } = await invokeLeaderboardRoute(null, {
|
||||
board: 'champions',
|
||||
period: 'all'
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.leaderboard.map(row => row.name)).toEqual([
|
||||
'MatchOutcome',
|
||||
'MatchLink',
|
||||
'CreditSolo',
|
||||
'LegacyDirect'
|
||||
]);
|
||||
expect(db.calls[0].params.slice(1, 3))
|
||||
.toEqual([['PAID_SINGLE', 'PAID_CREDITS'], false]);
|
||||
});
|
||||
|
||||
test('missing board defaults to Pleb and preserves free competitive rows', async () => {
|
||||
const { response, db } = await invokeLeaderboardRoute('such-play-wow-prestige', {
|
||||
period: 'all'
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.board).toBe('pleb');
|
||||
expect(response.body.leaderboard.map(row => row.name))
|
||||
.toEqual(['FreeMatch', 'FreeSolo']);
|
||||
expect(db.calls[0].params.slice(1, 3)).toEqual([['FREE'], false]);
|
||||
});
|
||||
|
||||
test.each(['all', 'unknown', ''])(
|
||||
'explicit deprecated or invalid board %p returns 400 without querying',
|
||||
async board => {
|
||||
const { response, db } = await invokeLeaderboardRoute(
|
||||
'such-play-wow-prestige',
|
||||
{ board }
|
||||
);
|
||||
expect(response.status).toBe(400);
|
||||
expect(response.body).toEqual(expect.objectContaining({
|
||||
error: 'INVALID_LEADERBOARD_BOARD',
|
||||
details: expect.objectContaining({
|
||||
allowedBoards: ['pleb', 'champions', 'prestige'],
|
||||
missingBoardDefault: 'pleb'
|
||||
})
|
||||
}));
|
||||
expect(db.calls).toHaveLength(0);
|
||||
}
|
||||
);
|
||||
});
|
||||
+19
-1
@@ -38,7 +38,8 @@ describe('production disclosure pages', () => {
|
||||
expect(html).toContain('FREE runs use the Pleb board');
|
||||
expect(html).toContain('PAID_SINGLE and PAID_CREDITS runs use the Hall of Champions');
|
||||
expect(html).toContain('credits_prestige matches use the Prestige board');
|
||||
expect(html).toContain('crypto_race matches use the Hall of Champions');
|
||||
expect(html).toContain('enabled crypto_race records Hall of Champions rows');
|
||||
expect(html).toContain('remain historical Hall of Champions results');
|
||||
});
|
||||
|
||||
test('generic self-hosted pages carry the MIT conditions and third-party operator disclaimer', () => {
|
||||
@@ -67,6 +68,9 @@ describe('production disclosure pages', () => {
|
||||
expect(html).toContain('offers no prizes, winnings, cash-out, or payouts');
|
||||
expect(html).toContain('not offered or marketed as gambling');
|
||||
expect(html).toContain('legal classification depends on applicable law');
|
||||
expect(html).toContain('Only PAID_CREDITS solo runs use the Hall of Champions');
|
||||
expect(html).toContain('historical PAID_SINGLE runs and match-generated game rows are excluded');
|
||||
expect(html).toContain('does not offer crypto_race');
|
||||
expect(html).not.toContain('NO REAL VALUE');
|
||||
});
|
||||
|
||||
@@ -86,5 +90,19 @@ describe('production disclosure pages', () => {
|
||||
expect(html).toContain('NO REAL VALUE');
|
||||
expect(html).toContain('Never send mainnet XMR');
|
||||
expect(html).toContain('no real-money or mainnet gambling is offered');
|
||||
|
||||
const terms = renderTerms(disclosure({
|
||||
OPERATED_PRODUCT_PROFILE: 'such-monerogue-stagenet'
|
||||
}, {
|
||||
cryptoType: 'XMR',
|
||||
currencyLabel: 'sXMR',
|
||||
network: 'stagenet',
|
||||
isTestNetwork: true,
|
||||
payoutsEnabled: true,
|
||||
isPayoutEnabledForMode: () => true
|
||||
}));
|
||||
expect(terms).toContain('PAID_SINGLE and PAID_CREDITS solo runs use the Hall of Champions');
|
||||
expect(terms).toContain('match-generated game rows are excluded');
|
||||
expect(terms).toContain('does not offer crypto_race');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,6 +54,9 @@ describe('operated product environment templates', () => {
|
||||
DIRECT_PAYOUTS_ENABLED: 'false',
|
||||
CREDITS_PAYOUTS_ENABLED: 'false',
|
||||
ALLOW_MAINNET_PAYOUTS: 'false',
|
||||
SOLO_ENABLED: 'true',
|
||||
TAVERN_ENABLED: 'true',
|
||||
MATCH_ENABLED: 'true',
|
||||
MATCH_CRYPTO_RACE_ENABLED: 'false',
|
||||
MATCH_PAYOUTS_ENABLED: 'false'
|
||||
}));
|
||||
@@ -84,6 +87,9 @@ describe('operated product environment templates', () => {
|
||||
CREDITS_PAYOUT_ESCAPE: '2.0',
|
||||
CREDITS_PAYOUT_TREASURE: '3.0',
|
||||
ALLOW_MAINNET_PAYOUTS: 'false',
|
||||
SOLO_ENABLED: 'true',
|
||||
TAVERN_ENABLED: 'true',
|
||||
MATCH_ENABLED: 'true',
|
||||
MATCH_CRYPTO_RACE_ENABLED: 'false',
|
||||
MATCH_PAYOUTS_ENABLED: 'false'
|
||||
}));
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
const {
|
||||
normalizeLeaderboardBoard,
|
||||
normalizeLeaderboardPeriod,
|
||||
prestigeCutoff,
|
||||
queryPrestigeLeaderboard
|
||||
queryPrestigeLeaderboard,
|
||||
querySoloLeaderboard,
|
||||
soloLeaderboardPolicy
|
||||
} = require('../src/network/prestigeLeaderboard');
|
||||
|
||||
describe('prestige leaderboard periods', () => {
|
||||
@@ -21,6 +24,58 @@ describe('prestige leaderboard periods', () => {
|
||||
expect(normalizeLeaderboardPeriod('YEAR')).toBe('all');
|
||||
});
|
||||
|
||||
test.each([
|
||||
['pleb', 'pleb'],
|
||||
['CHAMPIONS', 'champions'],
|
||||
[' prestige ', 'prestige'],
|
||||
[undefined, 'pleb'],
|
||||
[null, 'pleb'],
|
||||
['', null],
|
||||
['all', null],
|
||||
['unexpected', null]
|
||||
])('leaderboard board %p has an explicit, non-mixing API interpretation', (input, expected) => {
|
||||
expect(normalizeLeaderboardBoard(input)).toBe(expected);
|
||||
});
|
||||
|
||||
test('operated profile policies classify Champions from server identity', () => {
|
||||
expect(soloLeaderboardPolicy('such-play-wow-prestige', 'champions')).toEqual({
|
||||
gameModes: ['PAID_CREDITS'],
|
||||
excludeMatchGenerated: true
|
||||
});
|
||||
expect(soloLeaderboardPolicy('such-monerogue-stagenet', 'champions')).toEqual({
|
||||
gameModes: ['PAID_SINGLE', 'PAID_CREDITS'],
|
||||
excludeMatchGenerated: true
|
||||
});
|
||||
expect(soloLeaderboardPolicy(null, 'champions')).toEqual({
|
||||
gameModes: ['PAID_SINGLE', 'PAID_CREDITS'],
|
||||
excludeMatchGenerated: false
|
||||
});
|
||||
expect(soloLeaderboardPolicy('such-play-wow-prestige', 'pleb')).toEqual({
|
||||
gameModes: ['FREE'],
|
||||
excludeMatchGenerated: false
|
||||
});
|
||||
});
|
||||
|
||||
test('operated solo query excludes both durable match markers', async () => {
|
||||
const db = { query: jest.fn().mockResolvedValue({ rows: [] }) };
|
||||
await querySoloLeaderboard(db, {
|
||||
profileId: 'such-play-wow-prestige',
|
||||
board: 'champions',
|
||||
period: 'week',
|
||||
limit: 17,
|
||||
now
|
||||
});
|
||||
|
||||
const [sql, params] = db.query.mock.calls[0];
|
||||
expect(sql).toContain("LEFT(COALESCE(g.outcome, ''), 6) <> 'match_'");
|
||||
expect(sql).toContain('source_match.id::text = g.dungeon_seed');
|
||||
expect(sql).toContain('g.game_mode = ANY($2::varchar[])');
|
||||
expect(params[0].toISOString()).toBe('2026-07-14T16:00:00.000Z');
|
||||
expect(params[1]).toEqual(['PAID_CREDITS']);
|
||||
expect(params[2]).toBe(true);
|
||||
expect(params[3]).toBe(17);
|
||||
});
|
||||
|
||||
test.each(['week', 'month', 'all'])('queries match rows with a strict boundary for %s', async (period) => {
|
||||
const db = { query: jest.fn().mockResolvedValue({ rows: [] }) };
|
||||
await queryPrestigeLeaderboard(db, { period, limit: 17, now });
|
||||
|
||||
@@ -75,7 +75,10 @@ describe('public multiplayer controls and boards', () => {
|
||||
const matchHtml = fs.readFileSync(path.join(__dirname, '../html/match.html'), 'utf8');
|
||||
const tavernHtml = fs.readFileSync(path.join(__dirname, '../html/tavern.html'), 'utf8');
|
||||
const matchClient = fs.readFileSync(path.join(__dirname, '../html/js/matchClient.js'), 'utf8');
|
||||
const socketHandlers = fs.readFileSync(path.join(__dirname, '../html/js/network/socketHandlers.js'), 'utf8');
|
||||
const helpModal = fs.readFileSync(path.join(__dirname, '../html/js/ui/helpModal.js'), 'utf8');
|
||||
const leaderboard = fs.readFileSync(path.join(__dirname, '../html/js/ui/leaderboard.js'), 'utf8');
|
||||
const paymentUi = fs.readFileSync(path.join(__dirname, '../html/js/ui/paymentUI.js'), 'utf8');
|
||||
const designDoc = fs.readFileSync(path.join(__dirname, '../docs/TAVERN_AND_MULTIPLAYER.md'), 'utf8');
|
||||
|
||||
test('match and Tavern D-pads are named groups activated through native click', () => {
|
||||
@@ -92,6 +95,34 @@ describe('public multiplayer controls and boards', () => {
|
||||
expect(leaderboard).toContain('never mixed with Free or the Hall of Champions');
|
||||
});
|
||||
|
||||
test('arena renders only server-advertised economies, never locked out-of-profile cards', () => {
|
||||
expect(matchClient).toContain('availableKeys.forEach(function (key)');
|
||||
expect(matchClient).not.toContain('Object.keys(ECONOMIES).forEach(function (key)');
|
||||
expect(matchClient).not.toContain("avail.textContent = locked ? 'NOT ENABLED'");
|
||||
expect(tavernHtml).toContain('if (!economies[key]) return;');
|
||||
});
|
||||
|
||||
test('Wownero-facing solo and leaderboard copy uses entry/credits, not stake claims', () => {
|
||||
expect(socketHandlers).toContain('Choose your entry');
|
||||
expect(socketHandlers).not.toContain('Choose your stakes');
|
||||
expect(socketHandlers).toContain("Buy credits with ' + currency");
|
||||
expect(helpModal).toContain('Prefer a free entry?');
|
||||
expect(helpModal).not.toContain('Prefer no stakes?');
|
||||
expect(leaderboard).toContain("this._profileId === 'such-play-wow-prestige'");
|
||||
expect(leaderboard).toContain('Credit-entry solo scores only');
|
||||
expect(leaderboard).toContain('historical crypto-match results recorded while that mode was enabled');
|
||||
expect(leaderboard).not.toContain('crypto-stakes');
|
||||
});
|
||||
|
||||
test('direct-entry payment copy never claims it adds a spendable credit', () => {
|
||||
expect(socketHandlers).toContain('Buy a single entry or credits with ');
|
||||
expect(socketHandlers).toContain('SocketHandlers._directModeEnabled');
|
||||
expect(paymentUi).toContain('Single-game entry');
|
||||
expect(paymentUi).toContain('no spendable credit is added');
|
||||
expect(paymentUi).not.toContain('Single game <span');
|
||||
expect(paymentUi).not.toContain('Counts as 1 credit toward cosmetic unlocks');
|
||||
});
|
||||
|
||||
test('operator docs require restart for mode/ruleset changes and do not promise future combat', () => {
|
||||
expect(designDoc).toContain('restart the service');
|
||||
expect(designDoc).toContain('does not hot-reload match modes or rulesets');
|
||||
|
||||
@@ -6,6 +6,7 @@ const path = require('path');
|
||||
|
||||
const {
|
||||
LIVE_CONFIRM,
|
||||
OPERATED_PROFILE_ID,
|
||||
REQUIRED_MIGRATIONS,
|
||||
SAFE_PROFILE_CONFIRM,
|
||||
SCENARIOS,
|
||||
@@ -13,8 +14,10 @@ const {
|
||||
assertEmptyFinancialDatabase,
|
||||
assertInvoiceNotOwned,
|
||||
assertLiveSafety,
|
||||
assertPublicModeContract,
|
||||
canonicalAcknowledgement,
|
||||
chooseMove,
|
||||
enabledEconomyIds,
|
||||
readConfiguration,
|
||||
safeMessage,
|
||||
validateExpectedDatabaseName,
|
||||
@@ -114,9 +117,14 @@ describe('XMR stagenet financial canary safety contract', () => {
|
||||
});
|
||||
|
||||
test('builds exactly the current five-field stagenet acknowledgement', () => {
|
||||
const acknowledgement = canonicalAcknowledgement({
|
||||
const disclosure = {
|
||||
policyVersion: '2026-07-21-v2',
|
||||
paidAcknowledgementRequired: true,
|
||||
operatedProduct: {
|
||||
id: OPERATED_PROFILE_ID,
|
||||
scopeNotice: 'Single-player 2×/3× outcomes use test coins.',
|
||||
noRealValueNotice: 'NO REAL VALUE'
|
||||
},
|
||||
service: {
|
||||
cryptoType: 'XMR',
|
||||
network: 'stagenet',
|
||||
@@ -126,9 +134,11 @@ describe('XMR stagenet financial canary safety contract', () => {
|
||||
paidCreditsEnabled: true,
|
||||
soloPayoutsEnabled: true,
|
||||
anyPayoutsEnabled: true,
|
||||
paidPrestigeOnly: false
|
||||
paidPrestigeOnly: false,
|
||||
cryptoMatchPayoutsEnabled: false
|
||||
}
|
||||
});
|
||||
};
|
||||
const acknowledgement = canonicalAcknowledgement(disclosure);
|
||||
expect(acknowledgement).toEqual({
|
||||
policyVersion: '2026-07-21-v2',
|
||||
ageEligible: true,
|
||||
@@ -138,9 +148,18 @@ describe('XMR stagenet financial canary safety contract', () => {
|
||||
});
|
||||
expect(Object.keys(acknowledgement)).toHaveLength(5);
|
||||
expect(Object.isFrozen(acknowledgement)).toBe(true);
|
||||
expect(() => canonicalAcknowledgement({
|
||||
...disclosure,
|
||||
service: { ...disclosure.service, cryptoMatchPayoutsEnabled: true }
|
||||
})).toThrow(/payout-enabled paid solo modes/);
|
||||
expect(() => canonicalAcknowledgement({
|
||||
...disclosure,
|
||||
operatedProduct: { ...disclosure.operatedProduct, id: 'unreviewed-profile' }
|
||||
})).toThrow(/reviewed Such Software/);
|
||||
expect(() => canonicalAcknowledgement({
|
||||
policyVersion: 'v1',
|
||||
paidAcknowledgementRequired: true,
|
||||
operatedProduct: disclosure.operatedProduct,
|
||||
service: {
|
||||
cryptoType: 'XMR',
|
||||
network: 'mainnet',
|
||||
@@ -150,11 +169,84 @@ describe('XMR stagenet financial canary safety contract', () => {
|
||||
paidCreditsEnabled: true,
|
||||
soloPayoutsEnabled: true,
|
||||
anyPayoutsEnabled: true,
|
||||
paidPrestigeOnly: false
|
||||
paidPrestigeOnly: false,
|
||||
cryptoMatchPayoutsEnabled: false
|
||||
}
|
||||
})).toThrow(/stagenet/);
|
||||
});
|
||||
|
||||
test('requires the exact public profile and 2x/3x solo outcomes with crypto PvP off', () => {
|
||||
const modes = {
|
||||
operatedProductProfileId: OPERATED_PROFILE_ID,
|
||||
cryptoMatchPayoutsEnabled: false,
|
||||
soloEnabled: true,
|
||||
FREE: { enabled: true },
|
||||
PAID_SINGLE: {
|
||||
enabled: true,
|
||||
payoutMultiplier: { escape: 2, escapeWithTreasure: 3 }
|
||||
},
|
||||
PAID_CREDITS: {
|
||||
enabled: true,
|
||||
payoutMultiplier: { escape: 2, escapeWithTreasure: 3 }
|
||||
},
|
||||
match: {
|
||||
enabled: true,
|
||||
economies: {
|
||||
free: true,
|
||||
credits_prestige: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(() => assertPublicModeContract(modes)).not.toThrow();
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes, operatedProductProfileId: 'unreviewed-profile'
|
||||
})).toThrow(/reviewed no-crypto-PvP/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes, cryptoMatchPayoutsEnabled: true
|
||||
})).toThrow(/reviewed no-crypto-PvP/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes,
|
||||
soloEnabled: false
|
||||
})).toThrow(/original solo mode/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes,
|
||||
match: { ...modes.match, economies: { free: true } }
|
||||
})).toThrow(/free and credits-prestige/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes,
|
||||
match: {
|
||||
...modes.match,
|
||||
economies: {
|
||||
...modes.match.economies,
|
||||
crypto_race: true
|
||||
}
|
||||
}
|
||||
})).toThrow(/free and credits-prestige/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes,
|
||||
match: {
|
||||
...modes.match,
|
||||
economies: {
|
||||
...modes.match.economies,
|
||||
future_paid_mode: true
|
||||
}
|
||||
}
|
||||
})).toThrow(/free and credits-prestige/);
|
||||
expect(() => assertPublicModeContract({
|
||||
...modes,
|
||||
PAID_CREDITS: {
|
||||
...modes.PAID_CREDITS,
|
||||
payoutMultiplier: { escape: 2, escapeWithTreasure: 4 }
|
||||
}
|
||||
})).toThrow(/not exactly 3x/);
|
||||
expect(enabledEconomyIds({
|
||||
free: true,
|
||||
credits_prestige: true,
|
||||
crypto_race: false
|
||||
})).toEqual(['credits_prestige', 'free']);
|
||||
});
|
||||
|
||||
test('requires a scenario-named dedicated canary E2E database', () => {
|
||||
expect(() => validateExpectedDatabaseName(
|
||||
'monerogue_canary_direct_e2e', SCENARIOS['direct-2x']
|
||||
|
||||
Reference in New Issue
Block a user