From 82d456a38cb70c0cf7afd8ef0e8e7cb5f020e94c Mon Sep 17 00:00:00 2001 From: Samuel Siegart Date: Sun, 9 Feb 2025 14:13:21 -0800 Subject: [PATCH] wip: advance fail test with connection info --- .../test/fast-usdc/fast-usdc.test.ts | 1 - multichain-testing/test/support.ts | 20 ++++++++++++++ multichain-testing/tools/query.ts | 27 +++++++++++++------ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/multichain-testing/test/fast-usdc/fast-usdc.test.ts b/multichain-testing/test/fast-usdc/fast-usdc.test.ts index 4b42dfa1bfa..d4a2be8049e 100644 --- a/multichain-testing/test/fast-usdc/fast-usdc.test.ts +++ b/multichain-testing/test/fast-usdc/fast-usdc.test.ts @@ -492,7 +492,6 @@ test.serial('advance failed', async t => { nobleTools.mockCctpMint(mintAmt, userForwardingAddr); await assertTxStatus(evidence.txHash, 'FORWARD_FAILED'); - await sleep(5000, { log: t.log, setTimeout }); }); test.serial('lp withdraws', async t => { diff --git a/multichain-testing/test/support.ts b/multichain-testing/test/support.ts index 077246cc126..660a3614fee 100644 --- a/multichain-testing/test/support.ts +++ b/multichain-testing/test/support.ts @@ -102,6 +102,26 @@ export const commonSetup = async ( const unreachableChain: CosmosChainInfo = { chainId: 'unreachable-chain', bech32Prefix: 'unreachable', + connections: { + noblelocal: { + client_id: '07-tendermint-898989', + counterparty: { + client_id: '07-tendermint-989898', + connection_id: 'connection-767676', + }, + id: 'connection-424242', + state: 3, + transferChannel: { + channelId: 'channel-242424', + counterPartyChannelId: 'channel-656565', + counterPartyPortId: 'transfer', + ordering: 0, + portId: 'transfer', + state: 3, + version: 'ics20-1', + }, + }, + }, }; const chainInfo = { diff --git a/multichain-testing/tools/query.ts b/multichain-testing/tools/query.ts index b8633825ba4..e9501b221e2 100644 --- a/multichain-testing/tools/query.ts +++ b/multichain-testing/tools/query.ts @@ -21,14 +21,25 @@ type BlockHeaderPartial = { // TODO: inject fetch export function makeQueryClient(apiUrl: string) { const query = async (path: string): Promise => { - try { - const res = await fetch(`${apiUrl}${path}`); - const json = await res.json(); - return json as T; - } catch (err) { - console.error(err); - throw err; - } + const maxRetries = 5; + const retryDelayMS = 500; + return new Promise((resolve, reject) => { + const doFetch = async retries => { + try { + const response = await fetch(`${apiUrl}${path}`); + const json = await response.json(); + resolve(json as T); + } catch (err) { + if (retries === maxRetries) { + console.error(err); + reject(err); + return; + } + setTimeout(() => doFetch(retries + 1), retryDelayMS); + } + }; + doFetch(0); + }); }; return {