diff --git a/multichain-testing/test/config.ts b/multichain-testing/test/config.ts index 975c0d25e343..b163df624c71 100644 --- a/multichain-testing/test/config.ts +++ b/multichain-testing/test/config.ts @@ -41,3 +41,8 @@ export const MAKE_ACCOUNT_AND_QUERY_BALANCE_TIMEOUT: RetryOptions = { retryIntervalMs: 5000, maxRetries: 24, }; + +export const TWO_MINUTES: RetryOptions = { + retryIntervalMs: 5000, + maxRetries: 24, +}; diff --git a/multichain-testing/test/ica-channel-close.test.ts b/multichain-testing/test/ica-channel-close.test.ts index ec2d229bb9e3..aac5955fb5b3 100644 --- a/multichain-testing/test/ica-channel-close.test.ts +++ b/multichain-testing/test/ica-channel-close.test.ts @@ -12,6 +12,7 @@ import { import { makeQueryClient } from '../tools/query.js'; import { parseLocalAddress, parseRemoteAddress } from '../tools/address.js'; import chainInfo from '../starship-chain-info.js'; +import { TWO_MINUTES } from './config.js'; const test = anyTest as TestFn; @@ -182,6 +183,7 @@ const intentionalCloseAccountScenario = test.macro({ () => remoteQueryClient.queryChannels(), ({ channels }) => !!findNewChannel(channels, { rPortID, lPortID }), `ICA channel is reopened on ${chainName} Host`, + TWO_MINUTES, ); const newChannel = findNewChannel(channels, { rPortID, lPortID }); t.log('New Channel after Reactivate', newChannel); diff --git a/multichain-testing/tools/relayer-tools.ts b/multichain-testing/tools/relayer-tools.ts index ebf0562c204d..a79e769bed2a 100644 --- a/multichain-testing/tools/relayer-tools.ts +++ b/multichain-testing/tools/relayer-tools.ts @@ -3,23 +3,37 @@ import type { ExecSync } from './agd-lib.js'; const kubectlBinary = 'kubectl'; +type RelayerType = 'hermes' | 'go-relayer'; + // based on config.yaml -const relayerMap: { [key: string]: string } = { - osmosis: 'hermes-agoric-osmosis-0', - cosmoshub: 'hermes-agoric-gaia-0', +const chainRelayerConfig: { [key: string]: string } = { + osmosis: 'agoric-osmosis-0', + cosmoshub: 'agoric-gaia-0', +}; + +const getRelayerBinary = (relayer: RelayerType) => { + switch (relayer) { + case 'hermes': + return 'hermes'; + case 'go-relayer': + return 'rly'; + default: + throw new Error(`Unsupported relayer type: ${relayer}`); + } }; -const makeKubeArgs = (chainName: string) => { - if (!relayerMap[chainName]) throw Error('Unsupported chain: ' + chainName); +const makeKubeArgs = (chainName: string, relayerType: RelayerType) => { + if (!chainRelayerConfig[chainName]) + throw Error('Unsupported chain: ' + chainName); return [ 'exec', '-i', - relayerMap[chainName], + `${relayerType}-${chainRelayerConfig[chainName]}`, '-c', 'relayer', '--tty=false', '--', - 'hermes', + getRelayerBinary(relayerType), ]; }; @@ -38,11 +52,18 @@ type ChannelCloseParams = { }; export const makeRelayer = ({ execFileSync }: { execFileSync: ExecSync }) => { + const relayerType = (process.env.RELAYER_TYPE || 'hermes') as RelayerType; + const exec = ( chainName: string, args: string[], opts = { encoding: 'utf-8' as const, stdio: ['ignore', 'pipe', 'ignore'] }, - ) => execFileSync(kubectlBinary, [...makeKubeArgs(chainName), ...args], opts); + ) => + execFileSync( + kubectlBinary, + [...makeKubeArgs(chainName, relayerType), ...args], + opts, + ); /** Submit MsgChannelCloseInit to the src chain */ const channelCloseInit = ( @@ -50,17 +71,31 @@ export const makeRelayer = ({ execFileSync }: { execFileSync: ExecSync }) => { dst: ChannelCloseParams['dst'], src: ChannelCloseParams['src'], ) => { - return exec(chainName, [ - 'tx', - 'chan-close-init', - `--dst-chain=${dst.chainId}`, - `--src-chain=${src.chainId}`, - `--dst-connection=${dst.connectionID}`, - `--dst-port=${dst.portID}`, - `--src-port=${src.portID}`, - `--dst-channel=${dst.channelID}`, - `--src-channel=${src.channelID}`, - ]); + let args: string[]; + if (relayerType === 'hermes') { + args = [ + 'tx', + 'chan-close-init', + `--dst-chain=${dst.chainId}`, + `--src-chain=${src.chainId}`, + `--dst-connection=${dst.connectionID}`, + `--dst-port=${dst.portID}`, + `--src-port=${src.portID}`, + `--dst-channel=${dst.channelID}`, + `--src-channel=${src.channelID}`, + ]; + } else if (relayerType === 'go-relayer') { + args = [ + 'tx', + 'channel-close', + `${src.chainId}-${dst.chainId}`, // 'pathname' + src.channelID, + src.portID, + ]; + } else { + throw new Error(`Unsupported relayer type: ${relayerType}`); + } + return exec(chainName, args); }; return {