Some checks failed
deploy / deploy (push) Failing after 1m35s
Proof: first non-mocked tradeable loop for one pair using funded NEAR Intents inventory, Kafka, and PostgreSQL. Assumptions: solver-side execution is performed by signed token_diff quote responses over the Solver Relay; EURe is treated as 1:1 with EUR; k3s runtime uses unrip-dev.near as the named signer account. Still fake: signer key is not yet registered on intents.near, strategy and executor remain disarmed by default, and no live mainnet quote response has been submitted from this repo yet.
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { buildInventorySnapshot } from '../src/core/inventory.mjs';
|
|
import { routeHistoryRecord } from '../src/core/history-records.mjs';
|
|
|
|
test('inventory snapshot keeps pending funding out of spendable balances', () => {
|
|
const snapshot = buildInventorySnapshot({
|
|
accountId: 'solver.near',
|
|
balances: {
|
|
'nep141:btc.omft.near': '1000',
|
|
'nep141:eure.omft.near': '2000',
|
|
},
|
|
recentDeposits: [
|
|
{
|
|
asset_id: 'nep141:eure.omft.near',
|
|
amount: '300',
|
|
status: 'PENDING',
|
|
},
|
|
],
|
|
trackedWithdrawals: [
|
|
{
|
|
withdrawal_hash: 'wd-1',
|
|
asset_id: 'nep141:btc.omft.near',
|
|
amount: '25',
|
|
status: 'PENDING',
|
|
},
|
|
],
|
|
assetRegistry: new Map([
|
|
['nep141:btc.omft.near', { decimals: 8 }],
|
|
['nep141:eure.omft.near', { decimals: 18 }],
|
|
]),
|
|
observedAt: '2026-04-02T10:00:00.000Z',
|
|
});
|
|
|
|
assert.equal(snapshot.spendable['nep141:eure.omft.near'], '2000');
|
|
assert.equal(snapshot.pending_inbound['nep141:eure.omft.near'], '300');
|
|
assert.equal(snapshot.pending_outbound['nep141:btc.omft.near'], '25');
|
|
});
|
|
|
|
test('history writer routes decision events into the decision table family', () => {
|
|
const routed = routeHistoryRecord({
|
|
topic: 'decision.trade_decision',
|
|
event: {
|
|
event_id: 'evt-1',
|
|
event_type: 'trade_decision',
|
|
venue: 'near-intents',
|
|
schema_version: 1,
|
|
ingested_at: '2026-04-02T10:00:00.000Z',
|
|
payload: {
|
|
decision_id: 'decision-1',
|
|
quote_id: 'quote-1',
|
|
pair: 'a->b',
|
|
direction: 'btc_to_eure',
|
|
decision: 'rejected',
|
|
decision_reason: 'strategy_disarmed',
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(routed.table, 'trade_decisions');
|
|
assert.equal(routed.record.decision_key, 'decision-1');
|
|
assert.equal(routed.record.quote_id, 'quote-1');
|
|
});
|