unrip/test/price-route-runtime-static.test.mjs
philipp 0f33a53fa9
Some checks failed
deploy / deploy (push) Failing after 54s
Add BTC USDC price route
Proof: npm test passed 184/184; npm run operator-dashboard:build; focused route tests cover BTC/USDC route seeding, inventory tracking, Kraken/CoinGecko parsing, route-specific price selection, fresh BTC/USDC strategy approval, stale route blocking, and missing USDC reference fields.

Assumptions: BTC/USDC uses Kraken XBTUSDC as primary reference and CoinGecko bitcoin/USD as fallback with USDC ~= USD; operator-enabled maker pairs may mark their assets inventory-tracked, but imported assets remain non-trading by default.

Still fake: BTC/USDC taker request creation is not generalized; USDC/USD parity is an explicit assumption; solver liquidity and fee-complete PnL are not proven by this route.
2026-05-13 15:18:38 +02:00

21 lines
1.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const marketReferenceSource = readFileSync(new URL('../src/apps/market-reference-ingest.mjs', import.meta.url), 'utf8');
const strategyEngineSource = readFileSync(new URL('../src/apps/strategy-engine.mjs', import.meta.url), 'utf8');
test('market reference ingest publishes BTC/USDC route-specific prices', () => {
assert.match(marketReferenceSource, /XBTUSDC/);
assert.match(marketReferenceSource, /btc_usdc_reference/);
assert.match(marketReferenceSource, /usdc_per_btc/);
assert.match(marketReferenceSource, /buildPriceId\(now, referencePair\.priceRoute\.routeId\)/);
});
test('strategy engine stores and consumes latest prices by price route', () => {
assert.match(strategyEngineSource, /latest_price_events_by_route/);
assert.match(strategyEngineSource, /state\.latest_price_events_by_route\[routeId\] = event/);
assert.match(strategyEngineSource, /resolvePriceEventForDemand\(event, tradingConfig\)/);
assert.match(strategyEngineSource, /pair\?\.priceRoute\?\.routeId/);
assert.match(strategyEngineSource, /return state\.latest_price_events_by_route\[routeId\] \|\| null/);
});