unrip/test/history-writer-refresh-policy.test.mjs
philipp d151db1e91
Some checks failed
deploy / deploy (push) Failing after 31s
Let history writer catch up through stale backlog
Proof: npm test (140 passing); npm run operator-dashboard:build; git diff --cached --check.

Assumptions: Events older than HISTORY_WRITER_DERIVED_REFRESH_MAX_EVENT_AGE_MS are replay/backfill work; writing them remains required, but expensive derived portfolio/outcome refreshes can wait until the writer reaches fresh events.

Still fake: This does not move or migrate BTC assets; it only improves durable catch-up so fresh inventory can reach request preflight.
2026-05-07 16:13:21 +02:00

29 lines
877 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { shouldRunDerivedRefreshForEvent } from '../src/core/history-writer-refresh-policy.mjs';
test('history writer derived refresh policy skips stale replayed events', () => {
assert.equal(shouldRunDerivedRefreshForEvent({
event: {
ingested_at: '2026-05-05T07:56:03.203Z',
},
now: '2026-05-07T14:12:00.000Z',
maxEventAgeMs: 300000,
}), false);
});
test('history writer derived refresh policy runs for fresh and undated events', () => {
assert.equal(shouldRunDerivedRefreshForEvent({
event: {
ingested_at: '2026-05-07T14:11:52.729Z',
},
now: '2026-05-07T14:12:00.000Z',
maxEventAgeMs: 300000,
}), true);
assert.equal(shouldRunDerivedRefreshForEvent({
event: {},
now: '2026-05-07T14:12:00.000Z',
maxEventAgeMs: 300000,
}), true);
});