Skip to content

Commit

Permalink
test: deposit-withdraw requires asset info
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Nov 29, 2024
1 parent d89a727 commit 6c5db7f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
11 changes: 7 additions & 4 deletions multichain-testing/test/basic-flows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ const contractBuilder =
'../packages/builders/scripts/orchestration/init-basic-flows.js';

test.before(async t => {
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
const { setupTestKeys, ...common } = await commonSetup(t);
const { assetInfo, chainInfo, deleteTestKeys, startContract } = common;
deleteTestKeys(accounts).catch();
const wallets = await setupTestKeys(accounts);
t.context = { ...rest, wallets, deleteTestKeys };
const { startContract } = rest;
await startContract(contractName, contractBuilder);
t.context = { ...common, wallets };
await startContract(contractName, contractBuilder, {
chainInfo: JSON.stringify(chainInfo),
assetInfo: JSON.stringify(assetInfo),
});
});

test.after(async t => {
Expand Down
11 changes: 7 additions & 4 deletions multichain-testing/test/deposit-withdraw-lca.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const contractBuilder =
'../packages/builders/scripts/orchestration/init-basic-flows.js';

test.before(async t => {
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
const { setupTestKeys, ...common } = await commonSetup(t);
const { assetInfo, chainInfo, deleteTestKeys, startContract } = common;
deleteTestKeys(accounts).catch();
const wallets = await setupTestKeys(accounts);
t.context = { ...rest, wallets, deleteTestKeys };
const { startContract } = rest;
await startContract(contractName, contractBuilder);
t.context = { ...common, wallets };
await startContract(contractName, contractBuilder, {
chainInfo: JSON.stringify(chainInfo),
assetInfo: JSON.stringify(assetInfo),
});
});

test.after(async t => {
Expand Down
11 changes: 7 additions & 4 deletions multichain-testing/test/deposit-withdraw-portfolio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const contractBuilder =
'../packages/builders/scripts/orchestration/init-basic-flows.js';

test.before(async t => {
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
const { setupTestKeys, ...common } = await commonSetup(t);
const { assetInfo, chainInfo, deleteTestKeys, startContract } = common;
deleteTestKeys(accounts).catch();
const wallets = await setupTestKeys(accounts);
t.context = { ...rest, wallets, deleteTestKeys };
const { startContract } = rest;
await startContract(contractName, contractBuilder);
t.context = { ...common, wallets };
await startContract(contractName, contractBuilder, {
chainInfo: JSON.stringify(chainInfo),
assetInfo: JSON.stringify(assetInfo),
});
});

test.after(async t => {
Expand Down
11 changes: 7 additions & 4 deletions multichain-testing/test/ica-channel-close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const contractBuilder =
'../packages/builders/scripts/orchestration/init-basic-flows.js';

test.before(async t => {
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
const { setupTestKeys, ...common } = await commonSetup(t);
const { assetInfo, chainInfo, deleteTestKeys, startContract } = common;
deleteTestKeys(accounts).catch();
const wallets = await setupTestKeys(accounts);
t.context = { ...rest, wallets, deleteTestKeys };
const { startContract } = rest;
await startContract(contractName, contractBuilder);
t.context = { ...common, wallets };
await startContract(contractName, contractBuilder, {
chainInfo: JSON.stringify(chainInfo),
assetInfo: JSON.stringify(assetInfo),
});
});

test.after(async t => {
Expand Down
2 changes: 2 additions & 0 deletions multichain-testing/test/tools/asset-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ test('makeAssetInfo', async t => {
{
baseDenom: 'uist',
baseName: 'agoric',
brandKey: 'IST',
chainName: 'agoric',
},
],
Expand All @@ -88,6 +89,7 @@ test('makeAssetInfo', async t => {
{
baseDenom: 'ubld',
baseName: 'agoric',
brandKey: 'BLD',
chainName: 'agoric',
},
],
Expand Down
14 changes: 13 additions & 1 deletion multichain-testing/tools/asset-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export const makeAssetInfo = (
return `ibc/${denomHash({ denom, channelId })}`;
};

// `brandKey` instead of `brand` until #10580
// only BLD, IST until #9966
const BRAND_KEY_MAP: Record<string, string> = {
ubld: 'BLD',
uist: 'IST',
};

// only include chains present in `chainInfo`
const tokens = Object.entries(tokenMap)
.filter(([chain]) => chain in chainInfo)
Expand All @@ -55,18 +62,23 @@ export const makeAssetInfo = (
{
...baseDetails,
chainName: chain,
...(BRAND_KEY_MAP[denom] && { brandKey: BRAND_KEY_MAP[denom] }),
},
]);

// Add IBC entries for non-issuing chains
const issuingChainId = chainInfo[chain].chainId;
for (const holdingChain of Object.keys(chainInfo)) {
if (holdingChain === chain) continue;
const denomHash = toDenomHash(denom, issuingChainId, holdingChain);
assetInfo.push([
toDenomHash(denom, issuingChainId, holdingChain),
denomHash,
{
...baseDetails,
chainName: holdingChain,
...(BRAND_KEY_MAP[denomHash] && {
brandKey: BRAND_KEY_MAP[denomHash],
}),
},
]);
}
Expand Down

0 comments on commit 6c5db7f

Please sign in to comment.