difftreelog
Merge pull request #889 from UniqueNetwork/fix/acala-xcm-test-config
in: master
2 files changed
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth455 let balanceQuartzForeignTokenMiddle: bigint;455 let balanceQuartzForeignTokenMiddle: bigint;456 let balanceQuartzForeignTokenFinal: bigint;456 let balanceQuartzForeignTokenFinal: bigint;457458 // computed by a test transfer from prod Quartz to prod Karura.459 // 2 QTZ sent https://quartz.subscan.io/xcm_message/kusama-f60d821b049f8835a3005ce7102285006f5b61e9460 // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)461 const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;462463 const KARURA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedKaruraIncomeFee;457464458 before(async () => {465 before(async () => {459 await usingPlaygrounds(async (helper, privateKey) => {466 await usingPlaygrounds(async (helper, privateKey) => {474 };481 };475482476 const metadata = {483 const metadata = {477 name: 'QTZ',484 name: 'Quartz',478 symbol: 'QTZ',485 symbol: 'QTZ',479 decimals: 18,486 decimals: 18,480 minimalBalance: 1n,487 minimalBalance: 1000000000000000000n,481 };488 };482489483 await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);490 await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);550558551 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;553562554 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 };586602587 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);590606598 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));614 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));599615600 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 });603619604 await helper.wait.newBlocks(3);620 await helper.wait.newBlocks(3);609625610 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));611627612 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 });tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth455 let balanceUniqueForeignTokenMiddle: bigint;455 let balanceUniqueForeignTokenMiddle: bigint;456 let balanceUniqueForeignTokenFinal: bigint;456 let balanceUniqueForeignTokenFinal: bigint;457458 // computed by a test transfer from prod Unique to prod Acala.459 // 2 UNQ sent https://unique.subscan.io/xcm_message/polkadot-bad0b68847e2398af25d482e9ee6f9c1f9ec2a48460 // 1.898970000000000000 UNQ received (you can check Acala's chain state in the corresponding block)461 const expectedAcalaIncomeFee = 2000000000000000000n - 1898970000000000000n;462463 const ACALA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedAcalaIncomeFee;457464458 before(async () => {465 before(async () => {459 await usingPlaygrounds(async (helper, privateKey) => {466 await usingPlaygrounds(async (helper, privateKey) => {474 };481 };475482476 const metadata = {483 const metadata = {477 name: 'UNQ',484 name: 'Unique Network',478 symbol: 'UNQ',485 symbol: 'UNQ',479 decimals: 18,486 decimals: 18,480 minimalBalance: 1n,487 minimalBalance: 1250000000000000000n,481 };488 };482489483 await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);490 await helper.getSudo().assetRegistry.registerForeignAsset(alice, destination, metadata);552559553 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;560 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;554 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;561 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;562 const acaUnqFees = TRANSFER_AMOUNT - unqIncomeTransfer;555563556 console.log(564 console.log(557 '[Unique -> Acala] transaction fees on Acala: %s ACA',565 '[Unique -> Acala] transaction fees on Acala: %s ACA',558 helper.util.bigIntToDecimals(acaFees, ACALA_DECIMALS),566 helper.util.bigIntToDecimals(acaFees, ACALA_DECIMALS),559 );567 );568 console.log(569 '[Unique -> Acala] transaction fees on Acala: %s UNQ',570 helper.util.bigIntToDecimals(acaUnqFees),571 );560 console.log('[Unique -> Acala] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));572 console.log('[Unique -> Acala] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));561 expect(acaFees == 0n).to.be.true;573 expect(acaFees == 0n).to.be.true;562 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;574 expect(575 acaUnqFees == expectedAcalaIncomeFee,576 'Acala took different income fee, check the Acala foreign asset config',577 ).to.be.true;563 });578 });564 });579 });586 ForeignAsset: 0,601 ForeignAsset: 0,587 };602 };588603589 await helper.xTokens.transfer(randomAccount, id, TRANSFER_AMOUNT, destination, 'Unlimited');604 await helper.xTokens.transfer(randomAccount, id, ACALA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');590 balanceAcalaTokenFinal = await helper.balance.getSubstrate(randomAccount.address);605 balanceAcalaTokenFinal = await helper.balance.getSubstrate(randomAccount.address);591 balanceUniqueForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);606 balanceUniqueForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);592607600 console.log('[Acala -> Unique] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));615 console.log('[Acala -> Unique] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));601616602 expect(acaFees > 0, 'Negative fees ACA, looks like nothing was transferred').to.be.true;617 expect(acaFees > 0, 'Negative fees ACA, looks like nothing was transferred').to.be.true;603 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;618 expect(unqOutcomeTransfer == ACALA_BACKWARD_TRANSFER_AMOUNT).to.be.true;604 });619 });605620606 await helper.wait.newBlocks(3);621 await helper.wait.newBlocks(3);611626612 console.log('[Acala -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));627 console.log('[Acala -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));613628614 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;629 const unqFees = ACALA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;615 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));630 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));616 expect(unqFees == 0n).to.be.true;631 expect(unqFees == 0n).to.be.true;617 });632 });