git.delta.rocks / unique-network / refs/commits / 74b1ef40cf52

difftreelog

fix xcm tests

Daniel Shiposha2023-11-23parent: #c16a17a.patch.diff
in: master

5 files changed

modifiedjs-packages/playgrounds/unique.xcm.tsdiffbeforeafterboth
104}104}
105105
106export class ForeignAssetsGroup extends HelperGroup<UniqueHelper> {106export class ForeignAssetsGroup extends HelperGroup<UniqueHelper> {
107 async register(signer: TSigner, location: any, name: string, tokenPrefix: string, mode: 'NFT' | { Fungible: number }) {107 async register(signer: TSigner, assetId: any, name: string, tokenPrefix: string, mode: 'NFT' | { Fungible: number }) {
108 await this.helper.executeExtrinsic(108 await this.helper.executeExtrinsic(
109 signer,109 signer,
110 'api.tx.foreignAssets.forceRegisterForeignAsset',110 'api.tx.foreignAssets.forceRegisterForeignAsset',
111 [location, this.helper.util.str2vec(name), tokenPrefix, mode],111 [assetId, this.helper.util.str2vec(name), tokenPrefix, mode],
112 true,112 true,
113 );113 );
114 }114 }
115115
116 async foreignCollectionId(location: any) {116 async foreignCollectionId(assetId: any) {
117 return (await this.helper.callRpc('api.query.foreignAssets.foreignReserveLocationToCollection', [location])).toJSON();117 return (await this.helper.callRpc('api.query.foreignAssets.foreignAssetToCollection', [assetId])).toJSON();
118 }118 }
119}119}
120120
modifiedjs-packages/tests/xcm/xcm.types.tsdiffbeforeafterboth
512 parents: 1,512 parents: 1,
513 interior: 'Here',513 interior: 'Here',
514 };514 };
515 const relayAssetId = {Concrete: relayLocation};
515516
516 const relayCollectionId = await helper.foreignAssets.foreignCollectionId(relayLocation);517 const relayCollectionId = await helper.foreignAssets.foreignCollectionId(relayAssetId);
517 if(relayCollectionId == null) {518 if(relayCollectionId == null) {
518 const name = 'Relay Tokens';519 const name = 'Relay Tokens';
519 const tokenPrefix = 'xDOT';520 const tokenPrefix = 'xDOT';
520 const decimals = 10;521 const decimals = 10;
521 await helper.getSudo().foreignAssets.register(alice, relayLocation, name, tokenPrefix, {Fungible: decimals});522 await helper.getSudo().foreignAssets.register(alice, relayAssetId, name, tokenPrefix, {Fungible: decimals});
522523
523 return await helper.foreignAssets.foreignCollectionId(relayLocation);524 return await helper.foreignAssets.foreignCollectionId(relayAssetId);
524 } else {525 } else {
525 console.log('Relay foreign collection is already registered');526 console.log('Relay foreign collection is already registered');
526 return relayCollectionId;527 return relayCollectionId;
modifiedjs-packages/tests/xcm/xcmOpal.test.tsdiffbeforeafterboth
17import type {IKeyringPair} from '@polkadot/types/types';17import type {IKeyringPair} from '@polkadot/types/types';
18import config from '../config.js';18import config from '../config.js';
19import {itSub, expect, describeXCM, usingPlaygrounds, usingWestmintPlaygrounds, usingRelayPlaygrounds} from '../util/index.js';19import {itSub, expect, describeXCM, usingPlaygrounds, usingWestmintPlaygrounds, usingRelayPlaygrounds} from '../util/index.js';
20import {XcmTestHelper} from './xcm.types';20import {XcmTestHelper} from './xcm.types.js';
2121
22const STATEMINE_CHAIN = +(process.env.RELAY_WESTMINT_ID || 1000);22const STATEMINE_CHAIN = +(process.env.RELAY_WESTMINT_ID || 1000);
23const UNIQUE_CHAIN = +(process.env.RELAY_OPAL_ID || 2095);23const UNIQUE_CHAIN = +(process.env.RELAY_OPAL_ID || 2095);
120 },120 },
121 ]},121 ]},
122 };122 };
123 const assetId = {Concrete: location};
123124
124 if(await helper.foreignAssets.foreignCollectionId(location) == null) {125 if(await helper.foreignAssets.foreignCollectionId(assetId) == null) {
125 const tokenPrefix = USDT_ASSET_METADATA_NAME;126 const tokenPrefix = USDT_ASSET_METADATA_NAME;
126 await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS});127 await helper.getSudo().foreignAssets.register(
128 alice,
129 assetId,
130 USDT_ASSET_METADATA_NAME,
131 tokenPrefix,
132 {Fungible: USDT_ASSET_METADATA_DECIMALS},
133 );
127 } else {134 } else {
128 console.log('Foreign collection is already registered on Opal');135 console.log('Foreign collection is already registered on Opal');
129 }136 }
130137
131 balanceOpalBefore = await helper.balance.getSubstrate(alice.address);138 balanceOpalBefore = await helper.balance.getSubstrate(alice.address);
132 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location);139 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId);
133 });140 });
134141
135 // Providing the relay currency to the unique sender account142 // Providing the relay currency to the unique sender account
modifiedjs-packages/tests/xcm/xcmQuartz.test.tsdiffbeforeafterboth
19import {DevUniqueHelper, Event} from '@unique/playgrounds/unique.dev.js';19import {DevUniqueHelper, Event} from '@unique/playgrounds/unique.dev.js';
20import {STATEMINE_CHAIN, QUARTZ_CHAIN, KARURA_CHAIN, MOONRIVER_CHAIN, SHIDEN_CHAIN, STATEMINE_DECIMALS, KARURA_DECIMALS, QTZ_DECIMALS, RELAY_DECIMALS, SHIDEN_DECIMALS, karuraUrl, moonriverUrl, relayUrl, shidenUrl, statemineUrl} from './xcm.types.js';20import {STATEMINE_CHAIN, QUARTZ_CHAIN, KARURA_CHAIN, MOONRIVER_CHAIN, SHIDEN_CHAIN, STATEMINE_DECIMALS, KARURA_DECIMALS, QTZ_DECIMALS, RELAY_DECIMALS, SHIDEN_DECIMALS, karuraUrl, moonriverUrl, relayUrl, shidenUrl, statemineUrl} from './xcm.types.js';
21import {hexToString} from '@polkadot/util';21import {hexToString} from '@polkadot/util';
22import {XcmTestHelper} from './xcm.types';22import {XcmTestHelper} from './xcm.types.js';
2323
24const STATEMINE_PALLET_INSTANCE = 50;24const STATEMINE_PALLET_INSTANCE = 50;
2525
130 },130 },
131 ]},131 ]},
132 };132 };
133 const assetId = {Concrete: location};
133134
134 if(await helper.foreignAssets.foreignCollectionId(location) == null) {135 if(await helper.foreignAssets.foreignCollectionId(assetId) == null) {
135 const tokenPrefix = USDT_ASSET_METADATA_NAME;136 const tokenPrefix = USDT_ASSET_METADATA_NAME;
136 await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS});137 await helper.getSudo().foreignAssets.register(alice, assetId, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS});
137 } else {138 } else {
138 console.log('Foreign collection is already registered on Quartz');139 console.log('Foreign collection is already registered on Quartz');
139 }140 }
140141
141 balanceQuartzBefore = await helper.balance.getSubstrate(alice.address);142 balanceQuartzBefore = await helper.balance.getSubstrate(alice.address);
142 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location);143 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId);
143 });144 });
144145
145146
modifiedjs-packages/tests/xcm/xcmUnique.test.tsdiffbeforeafterboth
20import {Event} from '@unique/playgrounds/unique.dev.js';20import {Event} from '@unique/playgrounds/unique.dev.js';
21import {hexToString, nToBigInt} from '@polkadot/util';21import {hexToString, nToBigInt} from '@polkadot/util';
22import {ACALA_CHAIN, ASTAR_CHAIN, MOONBEAM_CHAIN, POLKADEX_CHAIN, SAFE_XCM_VERSION, STATEMINT_CHAIN, UNIQUE_CHAIN, expectFailedToTransact, expectUntrustedReserveLocationFail, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types.js';22import {ACALA_CHAIN, ASTAR_CHAIN, MOONBEAM_CHAIN, POLKADEX_CHAIN, SAFE_XCM_VERSION, STATEMINT_CHAIN, UNIQUE_CHAIN, expectFailedToTransact, expectUntrustedReserveLocationFail, uniqueAssetId, uniqueVersionedMultilocation} from './xcm.types.js';
23import {XcmTestHelper} from './xcm.types';23import {XcmTestHelper} from './xcm.types.js';
2424
25const STATEMINT_PALLET_INSTANCE = 50;25const STATEMINT_PALLET_INSTANCE = 50;
2626
142 },142 },
143 ]},143 ]},
144 };144 };
145 const assetId = {Concrete: location};
145146
146 if(await helper.foreignAssets.foreignCollectionId(location) == null) {147 if(await helper.foreignAssets.foreignCollectionId(assetId) == null) {
147 const tokenPrefix = USDT_ASSET_METADATA_NAME;148 const tokenPrefix = USDT_ASSET_METADATA_NAME;
148 await helper.getSudo().foreignAssets.register(alice, location, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS});149 await helper.getSudo().foreignAssets.register(alice, assetId, USDT_ASSET_METADATA_NAME, tokenPrefix, {Fungible: USDT_ASSET_METADATA_DECIMALS});
149 } else {150 } else {
150 console.log('Foreign collection is already registered on Unique');151 console.log('Foreign collection is already registered on Unique');
151 }152 }
152153
153 balanceUniqueBefore = await helper.balance.getSubstrate(alice.address);154 balanceUniqueBefore = await helper.balance.getSubstrate(alice.address);
154 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(location);155 usdtCollectionId = await helper.foreignAssets.foreignCollectionId(assetId);
155 });156 });
156157
157158