unrip/test/trade-executor-static.test.mjs
philipp 92aa636dc0
Some checks failed
deploy / deploy (push) Failing after 52s
Restore live trading under quote pressure
Proof: npm test (209/209) covers stale command expiry, bounded executor state, bounded strategy quote cache, bounded quote outcome refresh, and resource guardrails.

Assumptions: current DB pair config and armed state remain the operator-approved live trading controls; stale quote commands are unsafe to submit after their min_deadline_ms.

Still fake: quote outcomes still infer fills from inventory deltas rather than a venue-native terminal fill event.
2026-05-18 12:51:25 +02:00

27 lines
1.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = readFileSync(new URL('../src/apps/trade-executor.mjs', import.meta.url), 'utf8');
test('trade executor dispatches each execute command once', () => {
const calls = source.match(/await handleCommand\(event\);/g) || [];
assert.equal(calls.length, 1);
});
test('own request preflight suppresses maker quote responses to avoid self-matching', () => {
assert.match(source, /withMakerSuppressed/);
assert.match(source, /own_request_preflight_in_progress/);
assert.match(source, /avoid self-matching/);
});
test('trade executor fails closed on stale execute commands before relay submission', () => {
assert.match(source, /classifyExecuteCommandExpiry/);
assert.match(source, /stale_execute_command/);
assert.match(source, /deadline elapsed before relay submission/);
});
test('trade executor exposes summarized durable command state', () => {
assert.match(source, /stateStore\.getSummary\(\{ limit: 50 \}\)/);
assert.doesNotMatch(source, /durable_state:\s*stateStore\.getState\(\)/);
});