Some checks failed
deploy / deploy (push) Failing after 29s
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.
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
mapSupportedTokens,
|
|
refreshSupportedTokens,
|
|
} from '../src/core/liquidity-supported-tokens.mjs';
|
|
|
|
test('mapSupportedTokens indexes bridge tokens by near and intents identifiers', () => {
|
|
const mapped = mapSupportedTokens([
|
|
{
|
|
near_token_id: 'token.near',
|
|
defuse_asset_identifier: 'nep141:token.near',
|
|
decimals: 18,
|
|
},
|
|
]);
|
|
|
|
assert.deepEqual(Object.keys(mapped), ['token.near:nep141:token.near']);
|
|
assert.equal(mapped['token.near:nep141:token.near'].decimals, 18);
|
|
});
|
|
|
|
test('refreshSupportedTokens records warning state without throwing', async () => {
|
|
const state = {
|
|
supported_tokens: {
|
|
previous: { near_token_id: 'previous' },
|
|
},
|
|
};
|
|
const warnings = [];
|
|
|
|
const result = await refreshSupportedTokens({
|
|
bridgeClient: {
|
|
async supportedTokens() {
|
|
throw new Error('Bridge RPC supported_tokens failed');
|
|
},
|
|
},
|
|
chains: ['btc', 'gnosis'],
|
|
state,
|
|
logger: {
|
|
warn(event, fields) {
|
|
warnings.push({ event, fields });
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(result.ok, false);
|
|
assert.equal(state.supported_tokens.previous.near_token_id, 'previous');
|
|
assert.equal(state.supported_tokens_error.message, 'Bridge RPC supported_tokens failed');
|
|
assert.equal(warnings[0].event, 'supported_tokens_refresh_failed');
|
|
assert.deepEqual(warnings[0].fields.details.chains, ['btc', 'gnosis']);
|
|
});
|