git.delta.rocks / unique-network / refs/commits / 19aceb061355

difftreelog

fix karura test and typos

Daniel Shiposha2023-02-21parent: #418d2d5.patch.diff
in: master

2 files changed

modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
455 let balanceQuartzForeignTokenMiddle: bigint;455 let balanceQuartzForeignTokenMiddle: bigint;
456 let balanceQuartzForeignTokenFinal: bigint;456 let balanceQuartzForeignTokenFinal: bigint;
457
458 // computed by a test transfer from prod Quartz to prod Karura.
459 // 2 QTZ sent https://quartz.subscan.io/xcm_message/kusama-f60d821b049f8835a3005ce7102285006f5b61e9
460 // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)
461 const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;
462
463 const KARURA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedKaruraIncomeFee;
457464
458 before(async () => {465 before(async () => {
459 await usingPlaygrounds(async (helper, privateKey) => {466 await usingPlaygrounds(async (helper, privateKey) => {
550558
551 const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;559 const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;
552 const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;560 const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;
561 const karUnqFees = TRANSFER_AMOUNT - qtzIncomeTransfer;
553562
554 console.log(563 console.log(
555 '[Quartz -> Karura] transaction fees on Karura: %s KAR',564 '[Quartz -> Karura] transaction fees on Karura: %s KAR',
556 helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),565 helper.util.bigIntToDecimals(karFees, KARURA_DECIMALS),
557 );566 );
567 console.log(
568 '[Quartz -> Karura] transaction fees on Karura: %s QTZ',
569 helper.util.bigIntToDecimals(karUnqFees),
570 );
558 console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));571 console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));
559 expect(karFees == 0n).to.be.true;572 expect(karFees == 0n).to.be.true;
560 expect(qtzIncomeTransfer == TRANSFER_AMOUNT).to.be.true;573 expect(
574 karUnqFees == expectedKaruraIncomeFee,
575 'Karura took different income fee, check the Karura foreign asset config',
576 ).to.be.true;
561 });577 });
562 });578 });
584 ForeignAsset: 0,600 ForeignAsset: 0,
585 };601 };
586602
587 await helper.xTokens.transfer(randomAccount, id, TRANSFER_AMOUNT, destination, 'Unlimited');603 await helper.xTokens.transfer(randomAccount, id, KARURA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');
588 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);604 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);
589 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);605 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);
590606
598 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));614 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));
599615
600 expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;616 expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;
601 expect(qtzOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;617 expect(qtzOutcomeTransfer == KARURA_BACKWARD_TRANSFER_AMOUNT).to.be.true;
602 });618 });
603619
604 await helper.wait.newBlocks(3);620 await helper.wait.newBlocks(3);
609625
610 console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));626 console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));
611627
612 const qtzFees = TRANSFER_AMOUNT - actuallyDelivered;628 const qtzFees = KARURA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;
613 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));629 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));
614 expect(qtzFees == 0n).to.be.true;630 expect(qtzFees == 0n).to.be.true;
615 });631 });
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
441 });441 });
442});442});
443443
444describe.only('[XCM] Integration test: Exchanging tokens with Acala', () => {444describeXCM('[XCM] Integration test: Exchanging tokens with Acala', () => {
445 let alice: IKeyringPair;445 let alice: IKeyringPair;
446 let randomAccount: IKeyringPair;446 let randomAccount: IKeyringPair;
447447
457457
458 // computed by a test transfer from prod Unique to prod Acala.458 // computed by a test transfer from prod Unique to prod Acala.
459 // 2 UNQ sent https://unique.subscan.io/xcm_message/polkadot-bad0b68847e2398af25d482e9ee6f9c1f9ec2a48459 // 2 UNQ sent https://unique.subscan.io/xcm_message/polkadot-bad0b68847e2398af25d482e9ee6f9c1f9ec2a48
460 // 1.898970000000000000 UNQ received (you can check Acala's chain state in the coreesponding block)460 // 1.898970000000000000 UNQ received (you can check Acala's chain state in the corresponding block)
461 const expectedAcalaIncomeFee = 2000000000000000000n - 1898970000000000000n;461 const expectedAcalaIncomeFee = 2000000000000000000n - 1898970000000000000n;
462462
463 const ACALA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedAcalaIncomeFee;463 const ACALA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedAcalaIncomeFee;