Files
wownerogue/test/debugManagerHealth.test.js
jwinterm fad2a695bd Wownerogue
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.
2026-07-27 08:23:01 -04:00

33 lines
1.1 KiB
JavaScript

const DebugManager = require('../src/debug/debugManager');
describe('DebugManager daemon freshness', () => {
const originalEnv = process.env.NODE_ENV;
const originalSource = process.env.BLOCK_SOURCE;
beforeEach(() => {
process.env.NODE_ENV = 'production';
process.env.BLOCK_SOURCE = 'daemon';
});
afterAll(() => {
if (originalEnv === undefined) delete process.env.NODE_ENV;
else process.env.NODE_ENV = originalEnv;
if (originalSource === undefined) delete process.env.BLOCK_SOURCE;
else process.env.BLOCK_SOURCE = originalSource;
});
test('rejects a stale cached height until a recent RPC poll succeeds', () => {
const manager = new DebugManager({ broadcastBlockHeight: jest.fn() });
manager.lastProductionBlockHeight = 123;
manager.lastSuccessfulRpcAt = 0;
expect(manager.isChainHealthy()).toBe(false);
manager.lastSuccessfulRpcAt = Date.now();
expect(manager.isChainHealthy(1000)).toBe(true);
manager.lastSuccessfulRpcAt = Date.now() - 2000;
expect(manager.isChainHealthy(1000)).toBe(false);
});
});