Proof: npm test; node --check src/apps/inventory-sync.mjs; node --test test/inventory-sync-static.test.mjs test/trading-config.test.mjs. Assumptions: Inventory refresh failures should be logged with the active pair when available, but error logging must not throw if trading config loading or refresh work fails. Still fake: No BTC/USDC external reference price route or liquidity model exists; non-nBTC/EURe pairs still fail closed on missing price route until that path is built.
This commit is contained in:
parent
a0e7a698a1
commit
5805ea801d
2 changed files with 15 additions and 1 deletions
|
|
@ -136,8 +136,10 @@ await consumer.run({
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
if (state.paused) return;
|
if (state.paused) return;
|
||||||
|
|
||||||
|
let activePair = null;
|
||||||
try {
|
try {
|
||||||
const tradingConfig = await tradingConfigStore.getConfig();
|
const tradingConfig = await tradingConfigStore.getConfig();
|
||||||
|
activePair = tradingConfig.activePair;
|
||||||
if (!tradingConfig.ok) throw new Error(`trading config unavailable: ${tradingConfig.blockReason}`);
|
if (!tradingConfig.ok) throw new Error(`trading config unavailable: ${tradingConfig.blockReason}`);
|
||||||
const chains = uniqueChainsForAssets(tradingConfig.trackedAssets);
|
const chains = uniqueChainsForAssets(tradingConfig.trackedAssets);
|
||||||
const fallbackAssetByChain = new Map(
|
const fallbackAssetByChain = new Map(
|
||||||
|
|
@ -201,7 +203,7 @@ async function refresh() {
|
||||||
state.last_error = serializeError(error);
|
state.last_error = serializeError(error);
|
||||||
logger.error('inventory_refresh_failed', {
|
logger.error('inventory_refresh_failed', {
|
||||||
topic: config.kafkaTopicStateIntentInventory,
|
topic: config.kafkaTopicStateIntentInventory,
|
||||||
pair: tradingConfig.activePair,
|
pair: activePair,
|
||||||
details: {
|
details: {
|
||||||
error: serializeError(error),
|
error: serializeError(error),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
12
test/inventory-sync-static.test.mjs
Normal file
12
test/inventory-sync-static.test.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
const source = readFileSync(new URL('../src/apps/inventory-sync.mjs', import.meta.url), 'utf8');
|
||||||
|
|
||||||
|
test('inventory refresh error logging cannot reference block-scoped trading config', () => {
|
||||||
|
assert.match(source, /let activePair = null;/);
|
||||||
|
assert.match(source, /activePair = tradingConfig\.activePair;/);
|
||||||
|
assert.match(source, /pair: activePair/);
|
||||||
|
assert.doesNotMatch(source, /pair: tradingConfig\.activePair/);
|
||||||
|
});
|
||||||
Loading…
Add table
Reference in a new issue