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/); }); test('strategy control edge updates preserve DB-backed min notional policy', () => { assert.match(source, /path: '\/pair-config\/edge'/); assert.match(source, /minNotional: body\.min_notional/); });