"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const node_test_1 = require("node:test"); const strict_1 = __importDefault(require("node:assert/strict")); const keys_1 = require("../realtime/redis/keys"); const roundCache_1 = require("../realtime/redis/roundCache"); const poolCache_1 = require("../realtime/redis/poolCache"); const pubsub_1 = require("../realtime/redis/pubsub"); (0, node_test_1.describe)('redisKeys', () => { (0, node_test_1.test)('builds stable key names', () => { strict_1.default.equal(keys_1.redisKeys.config(), 'prediqo:cp:config'); strict_1.default.equal(keys_1.redisKeys.round(1, 1710000000000), 'prediqo:cp:round:1m:1710000000000'); strict_1.default.equal(keys_1.redisKeys.pools(3, 1710000000000), 'prediqo:cp:pools:3m:1710000000000'); strict_1.default.equal(keys_1.redisKeys.pubsubRound(1), 'prediqo:pubsub:cp:round:1m'); strict_1.default.equal(keys_1.redisKeys.pubsubUser('user-1'), 'prediqo:pubsub:cp:user:user-1'); }); }); (0, node_test_1.describe)('roundCache serialization', () => { (0, node_test_1.test)('round-trip round hash', () => { const dto = { id: 'round-1', candleOpenMs: 1710000000000, candleCloseMs: 1710000060000, intervalMinutes: 1, status: 'betting', outcome: null, openPrice: 100.5, highPrice: null, lowPrice: null, closePrice: null, settledAt: null, shortPoolPercent: 42, longPoolPercent: 58, serverNowMs: 1710000001500, secondsToBettingEnd: 25, secondsToBettingStart: 0, secondsToClose: 55, version: 3, }; const hash = (0, roundCache_1.serializeRoundToHash)(dto); const parsed = (0, roundCache_1.parseRoundFromHash)(hash); strict_1.default.deepEqual(parsed, dto); }); }); (0, node_test_1.describe)('poolCache serialization', () => { (0, node_test_1.test)('round-trip pool hash', () => { const pools = { short: 120.5, long: 80.25 }; const hash = (0, poolCache_1.serializePoolsToHash)(pools); strict_1.default.deepEqual((0, poolCache_1.parsePoolsFromHash)(hash), pools); }); }); (0, node_test_1.describe)('pubsub serialization', () => { (0, node_test_1.test)('round-trip realtime event', () => { const event = { type: 'round.updated', intervalMinutes: 1, payload: { status: 'betting' }, version: 2, ts: 1710000000000, }; const raw = (0, pubsub_1.serializeRealtimeEvent)(event); const parsed = (0, pubsub_1.parseRealtimeEvent)(raw); strict_1.default.deepEqual(parsed, event); }); (0, node_test_1.test)('normalizes missing payload to empty object (avoids WS crash)', () => { const parsed = (0, pubsub_1.parseRealtimeEvent)(JSON.stringify({ type: 'round.updated', intervalMinutes: 1, ts: 1 })); strict_1.default.ok(parsed); strict_1.default.equal(parsed.type, 'round.updated'); strict_1.default.deepEqual(parsed.payload, {}); }); }); //# sourceMappingURL=redisRealtime.test.js.map