unrip/test/liquidity-state.test.mjs
philipp 4bf15be22e
Some checks failed
deploy / deploy (push) Failing after 29s
Keep funding addresses refreshing without token list
Proof: supported_tokens bridge RPC failures no longer abort liquidity-manager deposit address refresh; regression tests cover the non-fatal warning path.

Assumptions: deposit handles remain chain-level NEAR Intents bridge data and Gnosis assets share the Gnosis handle when the bridge deposit_address RPC succeeds.

Still fake: USDC deposits are not proven credited yet; supported_tokens is still unavailable upstream until the bridge RPC responds successfully.
2026-05-13 15:43:37 +02:00

29 lines
1.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.equal(state.supported_tokens_error, null);
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);
});