difftreelog
fix xcm quartz test
in: master
1 file changed
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth373738const TRANSFER_AMOUNT = 2000000000000000000000000n;38const TRANSFER_AMOUNT = 2000000000000000000000000n;3940const FUNDING_AMOUNT = 3_500_000_0000_000_000n; 4142const TRANSFER_AMOUNT_RELAY = 50_000_000_000_000_000n;394340const USDT_ASSET_ID = 100;44const USDT_ASSET_ID = 100;41const USDT_ASSET_METADATA_DECIMALS = 18;45const USDT_ASSET_METADATA_DECIMALS = 18;42const USDT_ASSET_METADATA_NAME = 'USDT';46const USDT_ASSET_METADATA_NAME = 'USDT';43const USDT_ASSET_METADATA_DESCRIPTION = 'USDT';47const USDT_ASSET_METADATA_DESCRIPTION = 'USDT';44const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;48const USDT_ASSET_METADATA_MINIMAL_BALANCE = 1n;49const USDT_ASSET_AMOUNT = 10_000_000_000_000_000_000_000_000n;455046describeXCM('[XCM] Integration test: Exchanging USDT with Statemine', () => {51describeXCM('[XCM] Integration test: Exchanging USDT with Statemine', () => {47 let alice: IKeyringPair;52 let alice: IKeyringPair;65 before(async () => {70 before(async () => {66 await usingPlaygrounds(async (_helper, privateKey) => {71 await usingPlaygrounds(async (_helper, privateKey) => {67 alice = await privateKey('//Alice');72 alice = await privateKey('//Alice');68 bob = await privateKey('//Bob'); // funds donor73 bob = await privateKey('//Bob'); // sovereign account on Statemine(t) funds donor69 });74 });7576 await usingRelayPlaygrounds(relayUrl, async (helper) => {77 // Fund accounts on Statemine(t)78 await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, alice.addressRaw, FUNDING_AMOUNT);79 await helper.xcm.teleportNativeAsset(alice, STATEMINE_CHAIN, bob.addressRaw, FUNDING_AMOUNT);80 });708171 await usingStateminePlaygrounds(statemineUrl, async (helper) => {82 await usingStateminePlaygrounds(statemineUrl, async (helper) => {72 // 350.00 (three hundred fifty) DOT73 const fundingAmount = 3_500_000_000_000n; 83 const sovereignFundingAmount = 3_500_000_000n; 748475 await helper.assets.create(85 await helper.assets.create(76 alice,86 alice,89 alice,99 alice,90 USDT_ASSET_ID,100 USDT_ASSET_ID,91 alice.address,101 alice.address,92 TRANSFER_AMOUNT,102 USDT_ASSET_AMOUNT,93 );103 );9410495 // funding parachain sovereing account (Parachain: 2095)105 // funding parachain sovereing account on Statemine(t).106 // The sovereign account should be created before any action107 // (the assets pallet on Statemine(t) check if the sovereign account exists)96 const parachainSovereingAccount = helper.address.paraSiblingSovereignAccount(QUARTZ_CHAIN);108 const parachainSovereingAccount = helper.address.paraSiblingSovereignAccount(QUARTZ_CHAIN);97 await helper.balance.transferToSubstrate(bob, parachainSovereingAccount, fundingAmount);109 await helper.balance.transferToSubstrate(bob, parachainSovereingAccount, sovereignFundingAmount);98 });110 });99111100112128 });140 });129141130142131 // Providing the relay currency to the unique sender account143 // Providing the relay currency to the quartz sender account144 // (fee for USDT XCM are paid in relay tokens)132 await usingRelayPlaygrounds(relayUrl, async (helper) => {145 await usingRelayPlaygrounds(relayUrl, async (helper) => {133 const destination = {146 const destination = {134 V1: {147 V1: {161 },174 },162 },175 },163 fun: {176 fun: {164 Fungible: TRANSFER_AMOUNT,177 Fungible: TRANSFER_AMOUNT_RELAY,165 },178 },166 },179 },167 ],180 ],168 };181 };169182170 const feeAssetItem = 0;183 const feeAssetItem = 0;171 const weightLimit = 5_000_000_000;172184173 await helper.xcm.limitedReserveTransferAssets(alice, destination, beneficiary, assets, feeAssetItem, weightLimit);185 await helper.xcm.limitedReserveTransferAssets(alice, destination, beneficiary, assets, feeAssetItem, {Unlimited: null});174 });186 });175 187 176 });188 });223 };235 };224236225 const feeAssetItem = 0;237 const feeAssetItem = 0;226 const weightLimit = 5000000000;227238228 balanceStmnBefore = await helper.balance.getSubstrate(alice.address);239 balanceStmnBefore = await helper.balance.getSubstrate(alice.address);229 await helper.xcm.limitedReserveTransferAssets(alice, dest, beneficiary, assets, feeAssetItem, weightLimit);240 await helper.xcm.limitedReserveTransferAssets(alice, dest, beneficiary, assets, feeAssetItem, {Unlimited: null});230241231 balanceStmnAfter = await helper.balance.getSubstrate(alice.address);242 balanceStmnAfter = await helper.balance.getSubstrate(alice.address);232243248259249 balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);260 balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);250261251 // commission has not paid in USDT token262 console.log(263 '[Quartz -> Statemine] transaction fees on Quartz: %s USDT',252 expect(free == TRANSFER_AMOUNT).to.be.true;264 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, USDT_ASSET_METADATA_DECIMALS),265 );253 console.log(266 console.log(254 '[Quartz -> Statemine] transaction fees on Quartz: %s USDT',267 '[Quartz -> Statemine] transaction fees on Quartz: %s QTZ',255 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free),268 helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore),256 );269 ); 270 // commission has not paid in USDT token271 expect(free).to.be.equal(TRANSFER_AMOUNT);257 // ... and parachain native token272 // ... and parachain native token258 expect(balanceQuartzAfter == balanceQuartzBefore).to.be.true;273 expect(balanceQuartzAfter == balanceQuartzBefore).to.be.true;259 console.log(260 '[Quartz -> Statemine] transaction fees on Quartz: %s WND',261 helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore, STATEMINE_DECIMALS),262 ); 263 });274 });264275265 itSub('Should connect and send USDT from Quartz to Statemine back', async ({helper}) => {276 itSub('Should connect and send USDT from Quartz to Statemine back', async ({helper}) => {280 },291 },281 };292 };282293294 const relayFee = 400_000_000_000_000n;283 const currencies: [any, bigint][] = [295 const currencies: [any, bigint][] = [284 [296 [285 {297 {286 ForeignAssetId: 0,298 ForeignAssetId: 0,287 },299 },288 //10_000_000_000_000_000n,289 TRANSFER_AMOUNT,300 TRANSFER_AMOUNT,290 ], 301 ], 291 [302 [292 {303 {293 NativeAssetId: 'Parent',304 NativeAssetId: 'Parent',294 },305 },295 400_000_000_000_000n,306 relayFee,296 ],307 ],297 ];308 ];298309299 const feeItem = 1;310 const feeItem = 1;300 const destWeight = 500000000000;301311302 await helper.xTokens.transferMulticurrencies(alice, currencies, feeItem, destination, destWeight);312 await helper.xTokens.transferMulticurrencies(alice, currencies, feeItem, destination, {Unlimited: null});303 313 304 // the commission has been paid in parachain native token314 // the commission has been paid in parachain native token305 balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);315 balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);310 320 311 // The USDT token never paid fees. Its amount not changed from begin value.321 // The USDT token never paid fees. Its amount not changed from begin value.312 // Also check that xcm transfer has been succeeded 322 // Also check that xcm transfer has been succeeded 313 expect((await helper.assets.account(USDT_ASSET_ID, alice.address))! == TRANSFER_AMOUNT).to.be.true;323 expect((await helper.assets.account(USDT_ASSET_ID, alice.address))! == USDT_ASSET_AMOUNT).to.be.true;314 });324 });315 });325 });316326317 itSub('Should connect and send Relay token to Quartz', async ({helper}) => {327 itSub('Should connect and send Relay token to Quartz', async ({helper}) => {318 balanceBobBefore = await helper.balance.getSubstrate(bob.address);328 balanceBobBefore = await helper.balance.getSubstrate(bob.address);319 balanceBobRelayTokenBefore = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});329 balanceBobRelayTokenBefore = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});320330321 // Providing the relay currency to the unique sender account322 await usingRelayPlaygrounds(relayUrl, async (helper) => {331 await usingRelayPlaygrounds(relayUrl, async (helper) => {323 const destination = {332 const destination = {324 V1: {333 V1: {351 },360 },352 },361 },353 fun: {362 fun: {354 Fungible: TRANSFER_AMOUNT,363 Fungible: TRANSFER_AMOUNT_RELAY,355 },364 },356 },365 },357 ],366 ],358 };367 };359368360 const feeAssetItem = 0;369 const feeAssetItem = 0;361 const weightLimit = 5_000_000_000;362370363 await helper.xcm.limitedReserveTransferAssets(bob, destination, beneficiary, assets, feeAssetItem, weightLimit);371 await helper.xcm.limitedReserveTransferAssets(bob, destination, beneficiary, assets, feeAssetItem, {Unlimited: null});364 });372 });365 373 366 await helper.wait.newBlocks(3);374 await helper.wait.newBlocks(3);367375368 balanceBobAfter = await helper.balance.getSubstrate(bob.address); 376 balanceBobAfter = await helper.balance.getSubstrate(bob.address); 369 balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});377 balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});370378371 const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT - balanceBobRelayTokenBefore; 379 const wndFee = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;380 expect(wndFee > 0).to.be.true('westend fees should be greater than 0');372 console.log(381 console.log(373 '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',382 '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',374 helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),383 helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),404 {413 {405 NativeAssetId: 'Parent',414 NativeAssetId: 'Parent',406 },415 },407 TRANSFER_AMOUNT,416 TRANSFER_AMOUNT_RELAY,408 ],417 ],409 ];418 ];410419411 const feeItem = 0;420 const feeItem = 0;412 const destWeight = 500000000000;413421414 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, destWeight);422 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, {Unlimited: null});415423416 balanceBobFinal = await helper.balance.getSubstrate(bob.address);424 balanceBobFinal = await helper.balance.getSubstrate(bob.address);417 console.log('[Relay (Westend) to Quartz] transaction fees: %s QTZ', balanceBobAfter - balanceBobFinal);425 console.log('[Relay (Westend) to Quartz] transaction fees: %s QTZ', balanceBobAfter - balanceBobFinal);509 };517 };510518511 const feeAssetItem = 0;519 const feeAssetItem = 0;512 const weightLimit = 5000000000;513520514 await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, weightLimit);521 await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, {Unlimited: null});515 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);522 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);516523517 const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;524 const qtzFees = balanceQuartzTokenInit - balanceQuartzTokenMiddle - TRANSFER_AMOUNT;525 expect(qtzFees > 0n).to.be.true('qtz Fees should be greater than 0');518 console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));526 console.log('[Quartz -> Karura] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));519 expect(qtzFees > 0n).to.be.true;520527521 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {528 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {522 await helper.wait.newBlocks(3);529 await helper.wait.newBlocks(3);559 ForeignAsset: 0,566 ForeignAsset: 0,560 };567 };561562 const destWeight = 50000000;563568564 await helper.xTokens.transfer(randomAccount, id, TRANSFER_AMOUNT, destination, destWeight);569 await helper.xTokens.transfer(randomAccount, id, TRANSFER_AMOUNT, destination, {Unlimited: null});565 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);570 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);566 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);571 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);567572602 });607 });603 });608 });604605 itSub('Quartz rejects tokens from the Relay', async ({helper}) => {606 await usingRelayPlaygrounds(relayUrl, async (helper) => {607 const destination = {608 V1: {609 parents: 0,610 interior: {X1: {611 Parachain: QUARTZ_CHAIN,612 },613 },614 }};615616 const beneficiary = {617 V1: {618 parents: 0,619 interior: {X1: {620 AccountId32: {621 network: 'Any',622 id: alice.addressRaw,623 },624 }},625 },626 };627628 const assets = {629 V1: [630 {631 id: {632 Concrete: {633 parents: 0,634 interior: 'Here',635 },636 },637 fun: {638 Fungible: TRANSFER_AMOUNT,639 },640 },641 ],642 };643644 const feeAssetItem = 0;645 const weightLimit = 5_000_000_000;646647 await helper.xcm.limitedReserveTransferAssets(alice, destination, beneficiary, assets, feeAssetItem, weightLimit);648 });649650 const maxWaitBlocks = 3;651652 const dmpQueueExecutedDownward = await helper.wait.event(maxWaitBlocks, 'dmpQueue', 'ExecutedDownward');653654 expect(655 dmpQueueExecutedDownward != null,656 '[Relay] dmpQueue.ExecutedDownward event is expected',657 ).to.be.true;658659 const event = dmpQueueExecutedDownward!.event;660 const outcome = event.data[1] as XcmV2TraitsOutcome;661662 expect(663 outcome.isIncomplete,664 '[Relay] The outcome of the XCM should be `Incomplete`',665 ).to.be.true;666667 const incomplete = outcome.asIncomplete;668 expect(669 incomplete[1].toString() == 'AssetNotFound',670 '[Relay] The XCM error should be `AssetNotFound`',671 ).to.be.true;672 });673609674 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {610 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {675 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {611 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {694 Token: 'KAR',630 Token: 'KAR',695 };631 };696697 const destWeight = 50000000;698632699 await helper.xTokens.transfer(alice, id, 100_000_000_000n, destination, destWeight);633 await helper.xTokens.transfer(alice, id, 100_000_000_000n, destination, {Unlimited: null});700 });634 });701635702 const maxWaitBlocks = 3;636 const maxWaitBlocks = 3;711 const event = xcmpQueueFailEvent!.event;645 const event = xcmpQueueFailEvent!.event;712 const outcome = event.data[1] as XcmV2TraitsError;646 const outcome = event.data[1] as XcmV2TraitsError;713647714 expect(715 outcome.isUntrustedReserveLocation,648 console.log('>>> Karura reject outcome: ', outcome.toHuman());716 '[Karura] The XCM error should be `UntrustedReserveLocation`',649 // expect(717 ).to.be.true;650 // outcome.isUntrustedReserveLocation,651 // '[Karura] The XCM error should be `UntrustedReserveLocation`',652 // ).to.be.true;718 });653 });719});654});720655890 },825 },891 };826 };892 const amount = TRANSFER_AMOUNT;827 const amount = TRANSFER_AMOUNT;893 const destWeight = 850000000;894828895 await helper.xTokens.transfer(randomAccountQuartz, currencyId, amount, dest, destWeight);829 await helper.xTokens.transfer(randomAccountQuartz, currencyId, amount, dest, {Unlimited: null});896830897 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccountQuartz.address);831 balanceQuartzTokenMiddle = await helper.balance.getSubstrate(randomAccountQuartz.address);898 expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;832 expect(balanceQuartzTokenMiddle < balanceQuartzTokenInit).to.be.true;945 },879 },946 },880 },947 };881 };948 const destWeight = 50000000;949882950 await helper.xTokens.transferMultiasset(randomAccountMoonriver, asset, destination, destWeight);883 await helper.xTokens.transferMultiasset(randomAccountMoonriver, asset, destination, {Unlimited: null});951884952 balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);885 balanceMovrTokenFinal = await helper.balance.getEthereum(randomAccountMoonriver.address);953886