unrip/test/liquidity-state.test.mjs
philipp 860471f267
Some checks failed
deploy / deploy (push) Failing after 2s
Add pre-credit funding visibility and durable alerts
Proof: Implement the active turn for pre-credit funding visibility and durable operator alerts while keeping spendable inventory truth limited to bridge/verifier credit.

Assumptions: The BTC deposit handle can be observed through a mempool.space-compatible API, bridge recent_deposits remains the credit truth for correlation, and pausing market-reference-ingest or inventory-sync briefly for alert validation is safe without disarming strategy or executor.

Still fake: Gnosis pre-credit observation is not implemented, executor failure alert validation may still depend on an existing real failure unless a separate live failure is explicitly approved, and a new live deposit is still required to prove a fresh pre-credit-to-credit path if no suitable recent funding exists.
2026-04-03 17:50:39 +02:00

28 lines
1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { normalizeLiquidityState } from '../src/core/liquidity-state.mjs';
test('normalizeLiquidityState hydrates missing nested maps from persisted partial state', () => {
const state = normalizeLiquidityState(
{
last_refresh_at: null,
publish_count: 0,
},
{ withdrawalsFrozen: true },
);
assert.deepEqual(state.deposit_addresses, {});
assert.deepEqual(state.deposits, {});
assert.deepEqual(state.tracked_withdrawals, {});
assert.deepEqual(state.supported_tokens, {});
assert.deepEqual(state.funding_observations, {});
assert.deepEqual(state.funding_observations_by_handle, {});
assert.deepEqual(state.funding_visibility_by_asset, {});
assert.deepEqual(state.uncredited_funding_total_by_asset, {});
assert.deepEqual(state.credit_correlation, {});
assert.deepEqual(state.observer_health, {});
assert.equal(state.withdrawals_frozen, true);
assert.equal(state.paused, false);
assert.equal(state.funding_observer_paused, false);
});