All checks were successful
deploy / deploy (push) Successful in 33s
Proof: Live dashboard preflight waited through the generic 3s proxy timeout while trade-executor later recorded solver_quote_unanswered after the 10s relay quote wait. Request controls now use action-aware timeouts and unanswered requests render with plain reason text. Assumptions: Own-request preflight needs at least quote_timeout plus small overhead; submit needs publish plus relay-status wait. Generic service refresh controls should keep the shorter dashboard upstream timeout. Still fake: This does not create external solver liquidity; it only lets the dashboard observe whether the request was answered, submitted, or blocked without timing out first.
154 lines
5.8 KiB
JavaScript
154 lines
5.8 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
loadIntentRequestSubmissionsForStatusRefresh,
|
|
normalizeIntentRequestRow,
|
|
} from '../src/lib/postgres.mjs';
|
|
|
|
test('intent request normalization prefers terminal outcome reason text over relay acceptance text', () => {
|
|
const row = normalizeIntentRequestRow({
|
|
preflight_observed_at: '2026-04-12T16:45:30.000Z',
|
|
preflight_ingested_at: '2026-04-12T16:45:30.000Z',
|
|
preflight_payload: {
|
|
request_id: 'request-1',
|
|
idempotency_key: 'intent-request:request-1',
|
|
state: 'draft',
|
|
reason_code: 'quote_available',
|
|
reason_text: 'Solver quote meets the explicit slippage/minimum receive policy.',
|
|
source_asset_id: 'nep141:eure.omft.near',
|
|
source_symbol: 'EURe',
|
|
source_decimals: 18,
|
|
destination_asset_id: 'nep141:btc.omft.near',
|
|
destination_symbol: 'BTC',
|
|
destination_decimals: 8,
|
|
source_amount_units: '5000000000000000000',
|
|
min_destination_amount_units: '8090',
|
|
selected_quote: { quote_hash: 'quote-hash-1', amount_out: '8214' },
|
|
created_at: '2026-04-12T16:45:30.000Z',
|
|
deadline_at: '2026-04-12T16:46:28.790Z',
|
|
},
|
|
submission_observed_at: '2026-04-12T16:45:43.133Z',
|
|
submission_ingested_at: '2026-04-12T16:45:43.133Z',
|
|
submission_payload: {
|
|
request_id: 'request-1',
|
|
idempotency_key: 'intent-request:request-1',
|
|
submission_id: 'submission-1',
|
|
status: 'accepted_by_relay',
|
|
result_code: 'publish_intent_accepted',
|
|
result_text: 'Relay accepted the signed request. This is not settlement.',
|
|
submitted_at: '2026-04-12T16:45:43.133Z',
|
|
intent_hash: 'intent-hash-1',
|
|
quote_hash: 'quote-hash-1',
|
|
relay_status: 'PENDING',
|
|
destination_amount_units: '8214',
|
|
},
|
|
outcome_observed_at: '2026-04-12T16:47:32.958Z',
|
|
outcome_payload: {
|
|
request_id: 'request-1',
|
|
idempotency_key: 'intent-request:request-1',
|
|
submission_id: 'submission-1',
|
|
intent_hash: 'intent-hash-1',
|
|
submission_status: 'accepted_by_relay',
|
|
relay_status: 'PENDING',
|
|
submitted_at: '2026-04-12T16:45:43.133Z',
|
|
outcome_status: 'not_filled',
|
|
outcome_observed_at: '2026-04-12T16:47:32.958Z',
|
|
outcome_source: 'request_deadline_and_inventory_snapshots',
|
|
outcome_reason: 'deadline_elapsed_without_settlement',
|
|
attribution_status: 'unattributed',
|
|
attribution_method: null,
|
|
attributed_inventory_delta: null,
|
|
evidence: {},
|
|
},
|
|
});
|
|
|
|
assert.equal(row.state, 'not_filled');
|
|
assert.equal(row.reason_code, 'deadline_elapsed_without_settlement');
|
|
assert.match(row.reason_text, /Deadline and grace window elapsed/i);
|
|
assert.doesNotMatch(row.reason_text, /Relay accepted the signed request/i);
|
|
assert.equal(row.has_settlement_evidence, false);
|
|
});
|
|
|
|
|
|
test('intent request status refresh loader normalizes accepted relay submissions', async () => {
|
|
const queries = [];
|
|
const pool = {
|
|
async query(sql, params) {
|
|
queries.push({ sql, params });
|
|
return {
|
|
rows: [
|
|
{
|
|
observed_at: '2026-04-12T16:45:45.000Z',
|
|
ingested_at: '2026-04-12T16:45:46.000Z',
|
|
payload: {
|
|
request_id: 'request-1',
|
|
idempotency_key: 'intent-request:request-1',
|
|
submission_id: 'submission-1',
|
|
status: 'accepted_by_relay',
|
|
result_code: 'publish_intent_accepted',
|
|
result_text: 'Relay accepted the signed request. This is not settlement.',
|
|
submitted_at: '2026-04-12T16:45:43.133Z',
|
|
intent_hash: 'intent-hash-1',
|
|
quote_hash: 'quote-hash-1',
|
|
destination_amount_units: '8214',
|
|
nonce: 'nonce-1',
|
|
relay_status: 'PENDING',
|
|
relay_status_response: { status: 'PENDING' },
|
|
status_checked_at: '2026-04-12T16:45:44.000Z',
|
|
},
|
|
},
|
|
],
|
|
};
|
|
},
|
|
};
|
|
|
|
const [row] = await loadIntentRequestSubmissionsForStatusRefresh(pool, { limit: 3 });
|
|
|
|
assert.equal(queries[0].params[0], 3);
|
|
assert.equal(row.request_id, 'request-1');
|
|
assert.equal(row.idempotency_key, 'intent-request:request-1');
|
|
assert.equal(row.status, 'accepted_by_relay');
|
|
assert.equal(row.intent_hash, 'intent-hash-1');
|
|
assert.equal(row.relay_status, 'PENDING');
|
|
assert.equal(row.destination_amount_units, '8214');
|
|
assert.equal(row.submitted_at, '2026-04-12T16:45:43.133Z');
|
|
assert.equal(row.status_checked_at, '2026-04-12T16:45:44.000Z');
|
|
});
|
|
|
|
|
|
test('intent request normalization explains unanswered solver quotes in plain terms', () => {
|
|
const row = normalizeIntentRequestRow({
|
|
preflight_observed_at: '2026-04-12T17:20:19.476Z',
|
|
preflight_ingested_at: '2026-04-12T17:20:19.476Z',
|
|
preflight_payload: {
|
|
request_id: 'request-unanswered',
|
|
idempotency_key: 'intent-request:request-unanswered',
|
|
state: 'blocked',
|
|
reason_code: 'solver_quote_unanswered',
|
|
reason_text: 'The relay returned no solver quotes for this request.',
|
|
source_asset_id: 'nep141:eure.omft.near',
|
|
source_symbol: 'EURe',
|
|
source_decimals: 18,
|
|
destination_asset_id: 'nep141:btc.omft.near',
|
|
destination_symbol: 'BTC',
|
|
destination_decimals: 8,
|
|
source_amount_units: '5000000000000000000',
|
|
min_destination_amount_units: '8090',
|
|
solver_quote_count: 0,
|
|
created_at: '2026-04-12T17:20:19.476Z',
|
|
},
|
|
outcome_payload: {
|
|
request_id: 'request-unanswered',
|
|
outcome_status: 'blocked',
|
|
outcome_reason: 'solver_quote_unanswered',
|
|
attribution_status: 'unattributed',
|
|
attributed_inventory_delta: null,
|
|
},
|
|
});
|
|
|
|
assert.equal(row.state, 'blocked');
|
|
assert.equal(row.reason_code, 'solver_quote_unanswered');
|
|
assert.equal(row.reason_text, 'The relay returned no solver quotes for this request.');
|
|
assert.equal(row.live_submit_capable, false);
|
|
});
|