Skip to content

Commit

Permalink
Fix foreign assets smoke tests (#3106)
Browse files Browse the repository at this point in the history
* test(smoke): Fix foreign assets test

* test(smoke): mute hrmp channel check for Litmus parachain

* test(smoke): check asset status when verifying the live foreign assets
  • Loading branch information
RomarQ authored Dec 16, 2024
1 parent c28e349 commit 2fa9e6f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
6 changes: 6 additions & 0 deletions test/helpers/foreign-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export const ForeignChainsEndpoints = [
name: "Turing",
paraId: 2114,
},
// Litmus has become a para-thread
{
name: "Litmus",
paraId: 2106,
mutedUntil: new Date("2025-01-30").getTime(),
},
],
},
{
Expand Down
54 changes: 29 additions & 25 deletions test/suites/smoke/test-foreign-asset-consistency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,42 @@ describeSuite({
apiAt = await paraApi.at(await paraApi.rpc.chain.getBlockHash(atBlockNumber));
specVersion = apiAt.consts.system.version.specVersion.toNumber();

let query = await apiAt.query.assetManager.assetIdType.entries();
query.forEach(([key, exposure]) => {
liveForeignAssets = (await apiAt.query.assets.asset.entries()).reduce((acc, [key, value]) => {
acc[key.args.toString()] = (value.unwrap() as any).status.isLive;
return acc;
}, {});

// Query all assets mapped by identifier
const legacyAssets = await apiAt.query.assetManager.assetIdType.entries();
const evmForeignAssets = await apiAt.query.evmForeignAssets.assetsById.entries();
[...legacyAssets, ...evmForeignAssets].forEach(([key, exposure]) => {
const assetId = key.args.toString();
foreignAssetIdType[assetId] = exposure.unwrap().toString();
});
query = await apiAt.query.assetManager.assetTypeId.entries();
query.forEach(([key, exposure]) => {

// Query all assets mapped by location
const legacyAssetsByLocation = await apiAt.query.assetManager.assetTypeId.entries();
legacyAssetsByLocation.forEach(([key, exposure]) => {
const assetType = key.args.toString();
foreignAssetTypeId[assetType] = exposure.unwrap().toString();
});
const assetsByLocation = await apiAt.query.evmForeignAssets.assetsByLocation.entries();
assetsByLocation.forEach(([key, exposure]) => {
const assetType = key.args.toString();
const [assetId, assetStatus] = exposure.unwrap();
liveForeignAssets[assetType] = assetStatus.isActive;
foreignAssetTypeId[assetType] = assetId.toString();
});

if (specVersion >= 3200) {
query = await apiAt.query.xcmWeightTrader.supportedAssets.entries();
query.forEach(([key, _]) => {
const assetType = key.args.toString();
xcmWeightManagerSupportedAssets.push(assetType);
});
}
// log(`Foreign Xcm Accepted Assets: ${foreignXcmAcceptedAssets}`);
// log(`Foreign AssetId<->AssetType: ${JSON.stringify(foreignAssetIdType)}`);
// foreignAssetTypeId
// log(`Foreign AssetType<->AssetId: ${JSON.stringify(foreignAssetTypeId)}`);

if (specVersion >= 2200) {
liveForeignAssets = (await apiAt.query.assets.asset.entries()).reduce(
(acc, [key, value]) => {
acc[key.args.toString()] = (value.unwrap() as any).status.isLive;
return acc;
},
{} as any
);
}
// Query supported assets
(await apiAt.query.xcmWeightTrader.supportedAssets.entries()).forEach(([key, _]) => {
const assetType = key.args.toString();
xcmWeightManagerSupportedAssets.push(assetType);
});

log(`Foreign Xcm Supported Assets: ${xcmWeightManagerSupportedAssets}`);
log(`Foreign AssetId -> AssetLocation: ${JSON.stringify(foreignAssetIdType)}`);
log(`Foreign AssetLocation -> AssetId: ${JSON.stringify(foreignAssetTypeId)}`);
});

it({
Expand Down

0 comments on commit 2fa9e6f

Please sign in to comment.