All checks were successful
deploy / deploy (push) Successful in 43s
Proof: active BTC/EURe tradeable loop on k3s must expose funding state cleanly, preserve durable history, and avoid inheriting dummy executor state. Assumptions: retained Kafka topics may contain legacy dummy records; those should be tolerated in history ingestion without weakening the current live command shape. Still fake: internal inventory is still unfunded, strategy and executor remain disarmed, and no live quote response has been submitted yet.
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { routeHistoryRecord } from '../src/core/history-records.mjs';
|
|
|
|
test('history routing accepts legacy execute_trade records without decision metadata', () => {
|
|
const routed = routeHistoryRecord({
|
|
topic: 'cmd.execute_trade',
|
|
event: {
|
|
event_id: 'cmd-legacy-1',
|
|
event_type: 'execute_trade',
|
|
venue: 'near-intents',
|
|
schema_version: 1,
|
|
ingested_at: '2026-04-02T08:00:00.000Z',
|
|
payload: {
|
|
command_id: 'cmd-legacy-1',
|
|
idempotency_key: 'near-intents:legacy-1',
|
|
execution_key: 'near-intents:btc->eure',
|
|
quote_id: 'legacy-1',
|
|
asset_in: 'nep141:btc.omft.near',
|
|
asset_out: 'nep141:eure.omft.near',
|
|
amount_in: '100',
|
|
amount_out: '200',
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(routed.table, 'execute_trade_commands');
|
|
assert.equal(routed.record.decision_key, 'cmd-legacy-1');
|
|
});
|
|
|
|
test('history routing accepts legacy trade_result records without decision metadata', () => {
|
|
const routed = routeHistoryRecord({
|
|
topic: 'exec.trade_result',
|
|
event: {
|
|
event_id: 'result-legacy-1',
|
|
event_type: 'trade_result',
|
|
venue: 'near-intents',
|
|
schema_version: 1,
|
|
ingested_at: '2026-04-02T08:00:00.000Z',
|
|
payload: {
|
|
command_id: 'cmd-legacy-1',
|
|
idempotency_key: 'near-intents:legacy-1',
|
|
execution_key: 'near-intents:btc->eure',
|
|
quote_id: 'legacy-1',
|
|
status: 'simulated_sent',
|
|
result_code: 'sent',
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(routed.table, 'trade_execution_results');
|
|
assert.equal(routed.record.decision_key, 'cmd-legacy-1');
|
|
});
|