Skip to content

Commit

Permalink
test(multichain): commonAssetInfo support multi-env
Browse files Browse the repository at this point in the history
- support both `yarn test:main` and `yarn test:fast-usdc` which have different chainInfo
  • Loading branch information
0xpatrickdev committed Nov 28, 2024
1 parent f3810d0 commit af67a1f
Showing 1 changed file with 58 additions and 24 deletions.
82 changes: 58 additions & 24 deletions multichain-testing/test/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,65 @@ export const commonSetup = async (t: ExecutionContext) => {
const hermes = makeHermes(childProcess);
const nobleTools = makeNobleTools(childProcess);

// common assetInfo for contract chainHub
const commonAssetInfo: Record<string, DenomDetail> = {
uosmo: {
baseName: 'osmosis',
chainName: 'osmosis',
baseDenom: 'uosmo',
},
[`ibc/${denomHash({ denom: 'uosmo', channelId: starshipChainInfo.agoric.connections['osmosislocal'].transferChannel.channelId })}`]:
{
baseName: 'osmosis',
chainName: 'agoric',
baseDenom: 'uosmo',
},
uatom: {
baseName: 'cosmoshub',
chainName: 'cosmoshub',
baseDenom: 'uatom',
},
[`ibc/${denomHash({ denom: 'uatom', channelId: starshipChainInfo.agoric.connections['gaialocal'].transferChannel.channelId })}`]:
{
baseName: 'cosmoshub',
chainName: 'agoric',
baseDenom: 'uatom',
},
const makeCommonAssetInfo = () => {
const getChannelId = (
issuingChainId: string,
holdingChainName: string = 'agoric',
) => {
return starshipChainInfo[holdingChainName].connections[issuingChainId]
.transferChannel.channelId;
};

const uosmoOnAgoric = () =>
`ibc/${denomHash({ denom: 'uosmo', channelId: getChannelId('osmosislocal') })}`;
const uatomOnAgoric = () =>
`ibc/${denomHash({ denom: 'uatom', channelId: getChannelId('gaialocal') })}`;
const uusdcOnAgoric = () =>
`ibc/${denomHash({ denom: 'uusdc', channelId: getChannelId('noblelocal') })}`;

const assetInfo: Record<string, DenomDetail> = {};
for (const chain of Object.keys(starshipChainInfo)) {
if (chain === 'osmosis') {
assetInfo.uosmo = {
baseName: 'osmosis',
chainName: 'osmosis',
baseDenom: 'uosmo',
};
assetInfo[uosmoOnAgoric()] = {
baseName: 'osmosis',
chainName: 'agoric',
baseDenom: 'uosmo',
};
}
if (chain === 'cosmoshub') {
assetInfo.uatom = {
baseName: 'cosmoshub',
chainName: 'cosmoshub',
baseDenom: 'uatom',
};
assetInfo[uatomOnAgoric()] = {
baseName: 'cosmoshub',
chainName: 'agoric',
baseDenom: 'uatom',
};
}
if (chain === 'noble') {
assetInfo.uusdc = {
baseName: 'noble',
chainName: 'noble',
baseDenom: 'uusdc',
};
assetInfo[uusdcOnAgoric()] = {
baseName: 'noble',
chainName: 'agoric',
baseDenom: 'uusdc',
};
}
return assetInfo;
}
};
// common assetInfo for contract chainHub
const commonAssetInfo = makeCommonAssetInfo();

/**
* Starts a contract if instance not found. Takes care of installing
Expand Down

0 comments on commit af67a1f

Please sign in to comment.