unrip/test/history-writer-refresh-config.test.mjs
philipp 2ffa4b17f1
Some checks failed
deploy / deploy (push) Failing after 34s
Move trading config into Postgres
Proof: npm test passed 159/159; npm run operator-dashboard:build passed; repo-local Postgres importer smoke test imported 163 live 1Click tokens with only 3 inventory-enabled seed assets and nBTC/EURe pairs at 49 bps.

Assumptions: Forgejo main push is the repo deployment path; production has existing repo-managed POSTGRES_URL/POSTGRES_PASSWORD/NEAR_INTENTS_API_KEY secrets; startup seed may create initial current nBTC/EURe config but must preserve DB runtime pair flags after creation.

Still fake: no live funds movement was attempted; imported supported assets remain catalog-only unless explicitly enabled in DB; production rollout evidence still depends on the Forgejo deploy job completing after this push.
2026-05-12 21:34:58 +02:00

37 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { loadConfig } from '../src/lib/config.mjs';
const ENV_KEYS = [
'HISTORY_WRITER_DERIVED_REFRESH_MAX_EVENT_AGE_MS',
'INTENT_REQUEST_INVENTORY_MAX_AGE_MS',
];
function withCleanEnv(fn) {
const previous = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]]));
for (const key of ENV_KEYS) delete process.env[key];
try {
return fn();
} finally {
for (const [key, value] of Object.entries(previous)) {
if (value == null) delete process.env[key];
else process.env[key] = value;
}
}
}
test('history writer derived refresh replay cutoff keeps the approved default', () => withCleanEnv(() => {
const config = loadConfig({ envPath: '/tmp/unrip-no-such-env-file' });
assert.equal(config.historyWriterDerivedRefreshMaxEventAgeMs, 30000);
assert.equal(config.historyWriterDerivedRefreshMaxEventAgeMs, config.intentRequestInventoryMaxAgeMs);
}));
test('legacy request freshness env no longer ships in kubernetes config', () => {
const manifest = readFileSync(new URL('../deploy/k8s/base/unrip.yaml', import.meta.url), 'utf8');
assert.match(manifest, /HISTORY_WRITER_DERIVED_REFRESH_MAX_EVENT_AGE_MS: "30000"/);
assert.doesNotMatch(manifest, /INTENT_REQUEST_INVENTORY_MAX_AGE_MS/);
});