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.
33 lines
1.1 KiB
JavaScript
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);
|
|
});
|
|
});
|