git.delta.rocks / unique-network / refs/commits / 3e53a3185062

difftreelog

fix remove deprecated helpers from qtz xcm tests

Daniel Shiposha2022-10-11parent: #641d3fa.patch.diff
in: master

1 file changed

modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {Keyring} from '@polkadot/api';
18import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
19import {generateKeyringPair, bigIntToDecimals} from '../deprecated-helpers/helpers';
20import {blake2AsHex} from '@polkadot/util-crypto';18import {blake2AsHex} from '@polkadot/util-crypto';
21import {XcmV2TraitsOutcome, XcmV2TraitsError} from '../interfaces';19import {XcmV2TraitsOutcome, XcmV2TraitsError} from '../interfaces';
22import {itSub, expect, describeXcm, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds} from '../util/playgrounds';20import {itSub, expect, describeXcm, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds} from '../util/playgrounds';
5351
54 before(async () => {52 before(async () => {
55 await usingPlaygrounds(async (helper, privateKey) => {53 await usingPlaygrounds(async (helper, privateKey) => {
56 const keyringSr25519 = new Keyring({type: 'sr25519'});
57
58 alice = privateKey('//Alice');54 alice = privateKey('//Alice');
59 randomAccount = generateKeyringPair(keyringSr25519);55 [randomAccount] = await helper.arrange.createAccounts([0n], alice);
60 });56 });
6157
62 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {58 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
136 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);132 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);
137133
138 const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;134 const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
139 console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));135 console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));
140 expect(qtzFees > 0n).to.be.true;136 expect(qtzFees > 0n).to.be.true;
141137
142 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {138 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
149145
150 console.log(146 console.log(
151 '[Quartz -> Karura] transaction fees on Karura: %s KAR',147 '[Quartz -> Karura] transaction fees on Karura: %s KAR',
152 bigIntToDecimals(karFees, KARURA_DECIMALS),148 helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),
153 );149 );
154 console.log('[Quartz -> Karura] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));150 console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));
155 expect(karFees == 0n).to.be.true;151 expect(karFees == 0n).to.be.true;
156 expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;152 expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
157 });153 });
191187
192 console.log(188 console.log(
193 '[Karura -> Quartz] transaction fees on Karura: %s KAR',189 '[Karura -> Quartz] transaction fees on Karura: %s KAR',
194 bigIntToDecimals(karFees, KARURA_DECIMALS),190 helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),
195 );191 );
196 console.log('[Karura -> Quartz] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));192 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));
197193
198 expect(karFees > 0).to.be.true;194 expect(karFees > 0).to.be.true;
199 expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;195 expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
205 const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;201 const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
206 expect(actuallyDelivered > 0).to.be.true;202 expect(actuallyDelivered > 0).to.be.true;
207203
208 console.log('[Karura -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));204 console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));
209205
210 const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;206 const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
211 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));207 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));
212 expect(qtzFees == 0n).to.be.true;208 expect(qtzFees == 0n).to.be.true;
213 });209 });
214});210});
342describeXcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {338describeXcm('[XCM] Integration test: Exchanging QTZ with Moonriver', () => {
343339
344 // Quartz constants340 // Quartz constants
345 let quartzAlice: IKeyringPair;341 let quartzDonor: IKeyringPair;
346 let quartzAssetLocation;342 let quartzAssetLocation;
347343
348 let randomAccountQuartz: IKeyringPair;344 let randomAccountQuartz: IKeyringPair;
375 let balanceMovrTokenFinal: bigint;371 let balanceMovrTokenFinal: bigint;
376372
377 before(async () => {373 before(async () => {
378 await usingPlaygrounds(async (_helper, privateKey) => {374 await usingPlaygrounds(async (helper, privateKey) => {
379 const keyringEth = new Keyring({type: 'ethereum'});
380 const keyringSr25519 = new Keyring({type: 'sr25519'});
381
382 quartzAlice = privateKey('//Alice');375 quartzDonor = privateKey('//Alice');
383 randomAccountQuartz = generateKeyringPair(keyringSr25519);376 [randomAccountQuartz] = await helper.arrange.createAccounts([0n], quartzDonor);
384 randomAccountMoonriver = generateKeyringPair(keyringEth);
385377
386 balanceForeignQtzTokenInit = 0n;378 balanceForeignQtzTokenInit = 0n;
387 });379 });
391 const baltatharAccount = helper.account.baltatharAccount();383 const baltatharAccount = helper.account.baltatharAccount();
392 const dorothyAccount = helper.account.dorothyAccount();384 const dorothyAccount = helper.account.dorothyAccount();
385
386 randomAccountMoonriver = helper.account.create();
393387
394 // >>> Sponsoring Dorothy >>>388 // >>> Sponsoring Dorothy >>>
395 console.log('Sponsoring Dorothy.......');389 console.log('Sponsoring Dorothy.......');
493 });487 });
494488
495 await usingPlaygrounds(async (helper) => {489 await usingPlaygrounds(async (helper) => {
496 await helper.balance.transferToSubstrate(quartzAlice, randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);490 await helper.balance.transferToSubstrate(quartzDonor, randomAccountQuartz.address, 10n * TRANSFER_AMOUNT);
497 balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccountQuartz.address);491 balanceQuartzTokenInit = await helper.balance.getSubstrate(randomAccountQuartz.address);
498 });492 });
499 });493 });
522 expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;516 expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;
523517
524 const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;518 const transactionFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;
525 console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', bigIntToDecimals(transactionFees));519 console.log('[Quartz -> Moonriver] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(transactionFees));
526 expect(transactionFees > 0).to.be.true;520 expect(transactionFees > 0).to.be.true;
527521
528 await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {522 await usingMoonriverPlaygrounds(moonriverUrl, async (helper) => {
531 balanceMovrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonriver.address);525 balanceMovrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonriver.address);
532526
533 const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;527 const movrFees = balanceMovrTokenInit - balanceMovrTokenMiddle;
534 console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',bigIntToDecimals(movrFees));528 console.log('[Quartz -> Moonriver] transaction fees on Moonriver: %s MOVR',helper.util.bigIntToDecimals(movrFees));
535 expect(movrFees == 0n).to.be.true;529 expect(movrFees == 0n).to.be.true;
536530
537 balanceForeignQtzTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonriver.address))!; // BigInt(qtzRandomAccountAsset['balance']);531 balanceForeignQtzTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonriver.address))!; // BigInt(qtzRandomAccountAsset['balance']);
538 const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;532 const qtzIncomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenInit;
539 console.log('[Quartz -> Moonriver] income %s QTZ', bigIntToDecimals(qtzIncomeTransfer));533 console.log('[Quartz -> Moonriver] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));
540 expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;534 expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;
541 });535 });
542 });536 });
576 balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);570 balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);
577571
578 const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;572 const movrFees = balanceMovrTokenMiddle - balanceMovrTokenFinal;
579 console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', bigIntToDecimals(movrFees));573 console.log('[Moonriver -> Quartz] transaction fees on Moonriver: %s MOVR', helper.util.bigIntToDecimals(movrFees));
580 expect(movrFees > 0).to.be.true;574 expect(movrFees > 0).to.be.true;
581575
582 const qtzRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonriver.address);576 const qtzRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonriver.address);
586 balanceForeignQtzTokenFinal = 0n;580 balanceForeignQtzTokenFinal = 0n;
587581
588 const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;582 const qtzOutcomeTransfer = balanceForeignQtzTokenMiddle - balanceForeignQtzTokenFinal;
589 console.log('[Quartz -> Moonriver] outcome %s QTZ', bigIntToDecimals(qtzOutcomeTransfer));583 console.log('[Quartz -> Moonriver] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));
590 expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;584 expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;
591 });585 });
592586
596 const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;590 const actuallyDelivered = balanceQuartzTokenFinal - balanceQuartzTokenMiddle;
597 expect(actuallyDelivered > 0).to.be.true;591 expect(actuallyDelivered > 0).to.be.true;
598592
599 console.log('[Moonriver -> Quartz] actually delivered %s QTZ', bigIntToDecimals(actuallyDelivered));593 console.log('[Moonriver -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));
600594
601 const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;595 const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;
602 console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', bigIntToDecimals(qtzFees));596 console.log('[Moonriver -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));
603 expect(qtzFees == 0n).to.be.true;597 expect(qtzFees == 0n).to.be.true;
604 });598 });
605});599});