git.delta.rocks / unique-network / refs/commits / 48c1587fa96f

difftreelog

test fix pallet-tokens field name change

Yaroslav Bolyukin2022-09-16parent: #6ca971a.patch.diff
in: master

4 files changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -63,14 +63,14 @@
 export async function isQuartz(): Promise<boolean> {
   return usingApi(async api => {
     const chain = await api.rpc.system.chain();
-    
+
     return chain.eq('QUARTZ');
   });
 }
 
 let modulesNames: any;
 export function getModuleNames(api: ApiPromise): string[] {
-  if (typeof modulesNames === 'undefined') 
+  if (typeof modulesNames === 'undefined')
     modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());
   return modulesNames;
 }
@@ -304,7 +304,7 @@
 
 export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {
   const results: CreateItemResult[] = [];
-  
+
   const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {
     const collectionId = parseInt(data[0].toString(), 10);
     const itemId = parseInt(data[1].toString(), 10);
@@ -329,15 +329,15 @@
 
 export function getCreateItemResult(events: EventRecord[]): CreateItemResult {
   const genericResult = getGenericResult(events, 'common', 'ItemCreated', (data) => data.map(function(value) { return value.toJSON(); }));
-  
-  if (genericResult.data == null) 
+
+  if (genericResult.data == null)
     return {
       success: genericResult.success,
       collectionId: 0,
       itemId: 0,
       amount: 0,
     };
-  else 
+  else
     return {
       success: genericResult.success,
       collectionId: genericResult.data[0] as number,
@@ -349,7 +349,7 @@
 
 export function getDestroyItemsResult(events: EventRecord[]): DestroyItemResult[] {
   const results: DestroyItemResult[] = [];
-  
+
   const genericResult = getGenericResult<DestroyItemResult[]>(events, 'common', 'ItemDestroyed', (data) => {
     const collectionId = parseInt(data[0].toString(), 10);
     const itemId = parseInt(data[1].toString(), 10);
@@ -1151,9 +1151,9 @@
     expect(blockNumber).to.be.greaterThan(0);
     const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule
       scheduledId,
-      expectedBlockNumber, 
-      repetitions > 1 ? [period, repetitions] : null, 
-      0, 
+      expectedBlockNumber,
+      repetitions > 1 ? [period, repetitions] : null,
+      0,
       {Value: operationTx as any},
     );
 
@@ -1178,13 +1178,13 @@
     expect(blockNumber).to.be.greaterThan(0);
     const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule
       scheduledId,
-      expectedBlockNumber, 
-      repetitions <= 1 ? null : [period, repetitions], 
-      0, 
+      expectedBlockNumber,
+      repetitions <= 1 ? null : [period, repetitions],
+      0,
       {Value: operationTx as any},
     );
 
-    //const events = 
+    //const events =
     await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;
     //expect(getGenericResult(events).success).to.be.false;
   });
@@ -1248,7 +1248,7 @@
     const transferTx = api.tx.balances.transfer(recipient.address, amount);
 
     const balanceBefore = await getFreeBalance(recipient);
-    
+
     await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);
 
     expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
117 117
118 [balanceKaruraTokenInit] = await getBalance(api, [randomAccount.address]);118 [balanceKaruraTokenInit] = await getBalance(api, [randomAccount.address]);
119 {119 {
120 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;120 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
121 balanceQuartzForeignTokenInit = BigInt(free);121 balanceQuartzForeignTokenInit = BigInt(free);
122 }122 }
123 },123 },
200 await usingApi(200 await usingApi(
201 async (api) => {201 async (api) => {
202 await waitNewBlocks(api, 3);202 await waitNewBlocks(api, 3);
203 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;203 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
204 balanceQuartzForeignTokenMiddle = BigInt(free);204 balanceQuartzForeignTokenMiddle = BigInt(free);
205 205
206 [balanceKaruraTokenMiddle] = await getBalance(api, [randomAccount.address]);206 [balanceKaruraTokenMiddle] = await getBalance(api, [randomAccount.address]);
243 };243 };
244 244
245 const id = {245 const id = {
246 ForeignAsset: 0,246 ForeignAssetId: 0,
247 };247 };
248248
249 const destWeight = 50000000;249 const destWeight = 50000000;
255 255
256 [balanceKaruraTokenFinal] = await getBalance(api, [randomAccount.address]);256 [balanceKaruraTokenFinal] = await getBalance(api, [randomAccount.address]);
257 {257 {
258 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;258 const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
259 balanceQuartzForeignTokenFinal = BigInt(free);259 balanceQuartzForeignTokenFinal = BigInt(free);
260 }260 }
261 261
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -64,7 +64,7 @@
 describe_xcm('[XCM] Integration test: Exchanging tokens with Acala', () => {
   let alice: IKeyringPair;
   let randomAccount: IKeyringPair;
-  
+
   let balanceUniqueTokenInit: bigint;
   let balanceUniqueTokenMiddle: bigint;
   let balanceUniqueTokenFinal: bigint;
@@ -74,7 +74,7 @@
   let balanceUniqueForeignTokenInit: bigint;
   let balanceUniqueForeignTokenMiddle: bigint;
   let balanceUniqueForeignTokenFinal: bigint;
-  
+
   before(async () => {
     await usingApi(async (api, privateKeyWrapper) => {
       const keyringSr25519 = new Keyring({type: 'sr25519'});
@@ -96,50 +96,50 @@
             ],
           },
         };
-  
+
         const metadata = {
           name: 'UNQ',
           symbol: 'UNQ',
           decimals: 18,
           minimalBalance: 1,
         };
-  
+
         const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);
         const sudoTx = api.tx.sudo.sudo(tx as any);
         const events = await submitTransactionAsync(alice, sudoTx);
         const result = getGenericResult(events);
         expect(result.success).to.be.true;
-  
+
         const tx1 = api.tx.balances.transfer(randomAccount.address, 10000000000000n);
         const events1 = await submitTransactionAsync(alice, tx1);
         const result1 = getGenericResult(events1);
         expect(result1.success).to.be.true;
-  
+
         [balanceAcalaTokenInit] = await getBalance(api, [randomAccount.address]);
         {
-          const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+          const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
           balanceUniqueForeignTokenInit = BigInt(free);
         }
       },
       acalaOptions(),
     );
-  
+
     // Unique side
     await usingApi(async (api) => {
       const tx0 = api.tx.balances.transfer(randomAccount.address, 10n * TRANSFER_AMOUNT);
       const events0 = await submitTransactionAsync(alice, tx0);
       const result0 = getGenericResult(events0);
       expect(result0.success).to.be.true;
-  
+
       [balanceUniqueTokenInit] = await getBalance(api, [randomAccount.address]);
     });
   });
-  
+
   it('Should connect and send UNQ to Acala', async () => {
-  
+
     // Unique side
     await usingApi(async (api) => {
-  
+
       const destination = {
         V0: {
           X2: [
@@ -150,7 +150,7 @@
           ],
         },
       };
-  
+
       const beneficiary = {
         V0: {
           X1: {
@@ -161,7 +161,7 @@
           },
         },
       };
-  
+
       const assets = {
         V1: [
           {
@@ -177,32 +177,32 @@
           },
         ],
       };
-  
+
       const feeAssetItem = 0;
-  
+
       const weightLimit = {
         Limited: 5000000000,
       };
-  
+
       const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);
       const events = await submitTransactionAsync(randomAccount, tx);
       const result = getGenericResult(events);
       expect(result.success).to.be.true;
-  
+
       [balanceUniqueTokenMiddle] = await getBalance(api, [randomAccount.address]);
-  
+
       const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;
       console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));
       expect(unqFees > 0n).to.be.true;
     });
-  
+
     // Acala side
     await usingApi(
       async (api) => {
         await waitNewBlocks(api, 3);
-        const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+        const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
         balanceUniqueForeignTokenMiddle = BigInt(free);
-  
+
         [balanceAcalaTokenMiddle] = await getBalance(api, [randomAccount.address]);
 
         const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;
@@ -219,9 +219,9 @@
       acalaOptions(),
     );
   });
-  
+
   it('Should connect to Acala and send UNQ back', async () => {
-  
+
     // Acala side
     await usingApi(
       async (api) => {
@@ -241,24 +241,24 @@
             },
           },
         };
-  
+
         const id = {
-          ForeignAsset: 0,
+          ForeignAssetId: 0,
         };
 
         const destWeight = 50000000;
-  
+
         const tx = api.tx.xTokens.transfer(id as any, TRANSFER_AMOUNT, destination, destWeight);
         const events = await submitTransactionAsync(randomAccount, tx);
         const result = getGenericResult(events);
         expect(result.success).to.be.true;
-  
+
         [balanceAcalaTokenFinal] = await getBalance(api, [randomAccount.address]);
         {
-          const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+          const {free} = (await api.query.tokens.accounts(randomAccount.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
           balanceUniqueForeignTokenFinal = BigInt(free);
         }
-  
+
         const acaFees = balanceAcalaTokenMiddle - balanceAcalaTokenFinal;
         const unqOutcomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenFinal;
 
@@ -277,13 +277,13 @@
     // Unique side
     await usingApi(async (api) => {
       await waitNewBlocks(api, 3);
-  
+
       [balanceUniqueTokenFinal] = await getBalance(api, [randomAccount.address]);
       const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;
       expect(actuallyDelivered > 0).to.be.true;
 
       console.log('[Acala -> Unique] actually delivered %s UNQ', bigIntToDecimals(actuallyDelivered));
-  
+
       const unqFees = TRANSFER_AMOUNT - actuallyDelivered;
       console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));
       expect(unqFees == 0n).to.be.true;
@@ -300,7 +300,7 @@
       alice = privateKeyWrapper('//Alice');
     });
   });
-  
+
   it('Unique rejects tokens from the Relay', async () => {
     await usingApi(async (api) => {
       const destination = {
modifiedtests/src/xcmTransfer.test.tsdiffbeforeafterboth
--- a/tests/src/xcmTransfer.test.ts
+++ b/tests/src/xcmTransfer.test.ts
@@ -78,7 +78,7 @@
     let balanceOnKaruraBefore: bigint;
 
     await usingApi(async (api) => {
-      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
       balanceOnKaruraBefore = free;
     }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});
 
@@ -136,7 +136,7 @@
     await usingApi(async (api) => {
       // todo do something about instant sealing, where there might not be any new blocks
       await waitNewBlocks(api, 3);
-      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;
+      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAssetId: 0})).toJSON() as any;
       expect(free > balanceOnKaruraBefore).to.be.true;
     }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});
   });
@@ -165,7 +165,7 @@
       };
 
       const id = {
-        ForeignAsset: 0,
+        ForeignAssetId: 0,
       };
 
       const amount = TRANSFER_AMOUNT;