unrip/test/strategy-engine-static.test.mjs
philipp 365acf7b7f
All checks were successful
deploy / deploy (push) Successful in 46s
Add maker timing competitiveness truth
Proof: quote-to-relay maker timing now propagates through ingest, normalized quotes, strategy decisions, commands, executor results, quote outcomes, lifecycle rows, dashboard summaries, and runtime alerts; relay failures preserve original text while classifying quote_not_found_or_finished; targeted tests, full npm test, and operator dashboard build passed before commit.

Assumptions: response-age policy stays disabled by default and is only activated through DB-backed pair strategy config after operators review timing evidence; unrelated pre-existing dirty worktree files were left unstaged.

Still fake: relay acceptance is not settlement or realized PnL; live policy thresholds still require post-deploy evidence before enabling skips for production pairs.
2026-05-18 23:47:52 +02:00

22 lines
923 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = readFileSync(new URL('../src/apps/strategy-engine.mjs', import.meta.url), 'utf8');
test('strategy duplicate quote tracking is bounded and state-safe', () => {
assert.match(source, /createRecentIdCache\(\{ limit: 5000 \}\)/);
assert.match(source, /seenQuotes\.has/);
assert.match(source, /seenQuotes\.getState\(\)/);
assert.doesNotMatch(source, /seen_quotes:\s*\{\}/);
});
test('strategy execute commands stamp command publish time into durable observed time', () => {
assert.match(
source,
/const commandPublishedAt = new Date\(\)\.toISOString\(\)/,
);
assert.match(source, /command_published_at: commandPublishedAt/);
assert.match(source, /quote_age_at_command_ms: makerTiming\.quote_age_at_command_ms/);
assert.match(source, /observedAt:\s*commandPublishedAt/);
});