git.delta.rocks / unique-network / refs/commits / 33d49899f36c

difftreelog

Merge pull request #985 from UniqueNetwork/fix/xcm-release-60

Yaroslav Bolyukin2023-09-06parents: #432eea3 #bf4df5f.patch.diff
in: master

4 files changed

modified.baedeker/xcm-quartz.jsonnetdiffbeforeafterboth
82 wantedKeys: 'para-nimbus',82 wantedKeys: 'para-nimbus',
83 legacyRpc: true,83 legacyRpc: true,
84 },84 },
85 for name in ['alice', 'bob']85 for name in ['alith', 'baltathar']
86 },86 },
87};87};
8888
modified.baedeker/xcm-unique.jsonnetdiffbeforeafterboth
83 wantedKeys: 'para-nimbus',83 wantedKeys: 'para-nimbus',
84 legacyRpc: true,84 legacyRpc: true,
85 },85 },
86 for name in ['alice', 'bob']86 for name in ['alith', 'baltathar']
87 },87 },
88};88};
8989
modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
468 // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)468 // 1.919176000000000000 QTZ received (you can check Karura's chain state in the corresponding block)
469 const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;469 const expectedKaruraIncomeFee = 2000000000000000000n - 1919176000000000000n;
470
471 const KARURA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedKaruraIncomeFee;470 const karuraEps = 8n * 10n ** 16n;
471
472 let karuraBackwardTransferAmount: bigint;
472473
473 before(async () => {474 before(async () => {
474 await usingPlaygrounds(async (helper, privateKey) => {475 await usingPlaygrounds(async (helper, privateKey) => {
569570
570 const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;571 const karFees = balanceKaruraTokenInit - balanceKaruraTokenMiddle;
571 const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;572 const qtzIncomeTransfer = balanceQuartzForeignTokenMiddle - balanceQuartzForeignTokenInit;
573 karuraBackwardTransferAmount = qtzIncomeTransfer;
574
572 const karUnqFees = TRANSFER_AMOUNT - qtzIncomeTransfer;575 const karUnqFees = TRANSFER_AMOUNT - qtzIncomeTransfer;
573576
582 console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));585 console.log('[Quartz -> Karura] income %s QTZ', helper.util.bigIntToDecimals(qtzIncomeTransfer));
583 expect(karFees == 0n).to.be.true;586 expect(karFees == 0n).to.be.true;
587
588 const bigintAbs = (n: bigint) => (n < 0n) ? -n : n;
589
584 expect(590 expect(
585 karUnqFees == expectedKaruraIncomeFee,591 bigintAbs(karUnqFees - expectedKaruraIncomeFee) < karuraEps,
586 'Karura took different income fee, check the Karura foreign asset config',592 'Karura took different income fee, check the Karura foreign asset config',
587 ).to.be.true;593 ).to.be.true;
588 });594 });
611 ForeignAsset: 0,617 ForeignAsset: 0,
612 };618 };
613619
614 await helper.xTokens.transfer(randomAccount, id, KARURA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');620 await helper.xTokens.transfer(randomAccount, id, karuraBackwardTransferAmount, destination, 'Unlimited');
615 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);621 balanceKaruraTokenFinal = await helper.balance.getSubstrate(randomAccount.address);
616 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);622 balanceQuartzForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);
617623
625 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));631 console.log('[Karura -> Quartz] outcome %s QTZ', helper.util.bigIntToDecimals(qtzOutcomeTransfer));
626632
627 expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;633 expect(karFees > 0, 'Negative fees KAR, looks like nothing was transferred').to.be.true;
628 expect(qtzOutcomeTransfer == KARURA_BACKWARD_TRANSFER_AMOUNT).to.be.true;634 expect(qtzOutcomeTransfer == karuraBackwardTransferAmount).to.be.true;
629 });635 });
630636
631 await helper.wait.newBlocks(3);637 await helper.wait.newBlocks(3);
636642
637 console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));643 console.log('[Karura -> Quartz] actually delivered %s QTZ', helper.util.bigIntToDecimals(actuallyDelivered));
638644
639 const qtzFees = KARURA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;645 const qtzFees = karuraBackwardTransferAmount - actuallyDelivered;
640 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));646 console.log('[Karura -> Quartz] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(qtzFees));
641 expect(qtzFees == 0n).to.be.true;647 expect(qtzFees == 0n).to.be.true;
642 });648 });
673 );679 );
674680
675 let maliciousXcmProgramSent: any;681 let maliciousXcmProgramSent: any;
676 const maxWaitBlocks = 3;682 const maxWaitBlocks = 5;
677683
678 // Try to trick Quartz684 // Try to trick Quartz
679 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {685 await usingKaruraPlaygrounds(karuraUrl, async (helper) => {
682 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);688 maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
683 });689 });
684690
685 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash691 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
692 return event.messageHash == maliciousXcmProgramSent.messageHash
686 && event.outcome().isFailedToTransactAsset);693 && event.outcome.isFailedToTransactAsset;
694 });
687695
688 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);696 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
689 expect(targetAccountBalance).to.be.equal(0n);697 expect(targetAccountBalance).to.be.equal(0n);
764 });772 });
765773
766 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash774 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
767 && event.outcome().isUntrustedReserveLocation);775 && event.outcome.isUntrustedReserveLocation);
768776
769 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);777 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
770 expect(accountBalance).to.be.equal(0n);778 expect(accountBalance).to.be.equal(0n);
777 });785 });
778786
779 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash787 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
780 && event.outcome().isUntrustedReserveLocation);788 && event.outcome.isUntrustedReserveLocation);
781789
782 accountBalance = await helper.balance.getSubstrate(targetAccount.address);790 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
783 expect(accountBalance).to.be.equal(0n);791 expect(accountBalance).to.be.equal(0n);
853861
854 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {862 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
855 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash863 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
856 && event.outcome().isFailedToTransactAsset);864 && event.outcome.isFailedToTransactAsset);
857 };865 };
858866
859 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {867 itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
1165 });1173 });
11661174
1167 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash1175 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash
1168 && event.outcome().isFailedToTransactAsset);1176 && event.outcome.isFailedToTransactAsset);
11691177
1170 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1178 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1171 expect(targetAccountBalance).to.be.equal(0n);1179 expect(targetAccountBalance).to.be.equal(0n);
1254 });1262 });
12551263
1256 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash1264 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
1257 && event.outcome().isUntrustedReserveLocation);1265 && event.outcome.isUntrustedReserveLocation);
12581266
1259 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1267 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1260 expect(accountBalance).to.be.equal(0n);1268 expect(accountBalance).to.be.equal(0n);
1271 });1279 });
12721280
1273 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash1281 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
1274 && event.outcome().isUntrustedReserveLocation);1282 && event.outcome.isUntrustedReserveLocation);
12751283
1276 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1284 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1277 expect(accountBalance).to.be.equal(0n);1285 expect(accountBalance).to.be.equal(0n);
1531 });1539 });
15321540
1533 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash1541 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash
1534 && event.outcome().isFailedToTransactAsset);1542 && event.outcome.isFailedToTransactAsset);
15351543
1536 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1544 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1537 expect(targetAccountBalance).to.be.equal(0n);1545 expect(targetAccountBalance).to.be.equal(0n);
1612 });1620 });
16131621
1614 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash1622 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
1615 && event.outcome().isUntrustedReserveLocation);1623 && event.outcome.isUntrustedReserveLocation);
16161624
1617 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1625 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1618 expect(accountBalance).to.be.equal(0n);1626 expect(accountBalance).to.be.equal(0n);
1625 });1633 });
16261634
1627 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash1635 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
1628 && event.outcome().isUntrustedReserveLocation);1636 && event.outcome.isUntrustedReserveLocation);
16291637
1630 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1638 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1631 expect(accountBalance).to.be.equal(0n);1639 expect(accountBalance).to.be.equal(0n);
modifiedtests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth
8484
85 await usingRelayPlaygrounds(relayUrl, async (helper) => {85 await usingRelayPlaygrounds(relayUrl, async (helper) => {
86 // Fund accounts on Statemint86 // Fund accounts on Statemint
87 const relayXcmVersion = 2;
88 await helper.xcm.teleportNativeAsset(alice, STATEMINT_CHAIN, alice.addressRaw, FUNDING_AMOUNT, relayXcmVersion);87 await helper.xcm.teleportNativeAsset(alice, STATEMINT_CHAIN, alice.addressRaw, FUNDING_AMOUNT);
89 await helper.xcm.teleportNativeAsset(alice, STATEMINT_CHAIN, bob.addressRaw, FUNDING_AMOUNT, relayXcmVersion);88 await helper.xcm.teleportNativeAsset(alice, STATEMINT_CHAIN, bob.addressRaw, FUNDING_AMOUNT);
90 });89 });
9190
92 await usingStatemintPlaygrounds(statemintUrl, async (helper) => {91 await usingStatemintPlaygrounds(statemintUrl, async (helper) => {
154 // (fee for USDT XCM are paid in relay tokens)153 // (fee for USDT XCM are paid in relay tokens)
155 await usingRelayPlaygrounds(relayUrl, async (helper) => {154 await usingRelayPlaygrounds(relayUrl, async (helper) => {
156 const destination = {155 const destination = {
157 V1: {156 V2: {
158 parents: 0,157 parents: 0,
159 interior: {X1: {158 interior: {X1: {
160 Parachain: UNIQUE_CHAIN,159 Parachain: UNIQUE_CHAIN,
163 }};162 }};
164163
165 const beneficiary = {164 const beneficiary = {
166 V1: {165 V2: {
167 parents: 0,166 parents: 0,
168 interior: {X1: {167 interior: {X1: {
169 AccountId32: {168 AccountId32: {
175 };174 };
176175
177 const assets = {176 const assets = {
178 V1: [177 V2: [
179 {178 {
180 id: {179 id: {
181 Concrete: {180 Concrete: {
200 itSub('Should connect and send USDT from Statemint to Unique', async ({helper}) => {199 itSub('Should connect and send USDT from Statemint to Unique', async ({helper}) => {
201 await usingStatemintPlaygrounds(statemintUrl, async (helper) => {200 await usingStatemintPlaygrounds(statemintUrl, async (helper) => {
202 const dest = {201 const dest = {
203 V1: {202 V2: {
204 parents: 1,203 parents: 1,
205 interior: {X1: {204 interior: {X1: {
206 Parachain: UNIQUE_CHAIN,205 Parachain: UNIQUE_CHAIN,
209 }};208 }};
210209
211 const beneficiary = {210 const beneficiary = {
212 V1: {211 V2: {
213 parents: 0,212 parents: 0,
214 interior: {X1: {213 interior: {X1: {
215 AccountId32: {214 AccountId32: {
221 };220 };
222221
223 const assets = {222 const assets = {
224 V1: [223 V2: [
225 {224 {
226 id: {225 id: {
227 Concrete: {226 Concrete: {
341340
342 await usingRelayPlaygrounds(relayUrl, async (helper) => {341 await usingRelayPlaygrounds(relayUrl, async (helper) => {
343 const destination = {342 const destination = {
344 V1: {343 V2: {
345 parents: 0,344 parents: 0,
346 interior: {X1: {345 interior: {X1: {
347 Parachain: UNIQUE_CHAIN,346 Parachain: UNIQUE_CHAIN,
350 }};349 }};
351350
352 const beneficiary = {351 const beneficiary = {
353 V1: {352 V2: {
354 parents: 0,353 parents: 0,
355 interior: {X1: {354 interior: {X1: {
356 AccountId32: {355 AccountId32: {
362 };361 };
363362
364 const assets = {363 const assets = {
365 V1: [364 V2: [
366 {365 {
367 id: {366 id: {
368 Concrete: {367 Concrete: {
469 // 1.898970000000000000 UNQ received (you can check Acala's chain state in the corresponding block)468 // 1.898970000000000000 UNQ received (you can check Acala's chain state in the corresponding block)
470 const expectedAcalaIncomeFee = 2000000000000000000n - 1898970000000000000n;469 const expectedAcalaIncomeFee = 2000000000000000000n - 1898970000000000000n;
471
472 const ACALA_BACKWARD_TRANSFER_AMOUNT = TRANSFER_AMOUNT - expectedAcalaIncomeFee;470 const acalaEps = 8n * 10n ** 16n;
471
472 let acalaBackwardTransferAmount: bigint;
473473
474 before(async () => {474 before(async () => {
475 await usingPlaygrounds(async (helper, privateKey) => {475 await usingPlaygrounds(async (helper, privateKey) => {
482482
483 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {483 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
484 const destination = {484 const destination = {
485 V1: {485 V2: {
486 parents: 1,486 parents: 1,
487 interior: {487 interior: {
488 X1: {488 X1: {
571571
572 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;572 const acaFees = balanceAcalaTokenInit - balanceAcalaTokenMiddle;
573 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;573 const unqIncomeTransfer = balanceUniqueForeignTokenMiddle - balanceUniqueForeignTokenInit;
574 acalaBackwardTransferAmount = unqIncomeTransfer;
575
574 const acaUnqFees = TRANSFER_AMOUNT - unqIncomeTransfer;576 const acaUnqFees = TRANSFER_AMOUNT - unqIncomeTransfer;
575577
584 console.log('[Unique -> Acala] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));586 console.log('[Unique -> Acala] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));
585 expect(acaFees == 0n).to.be.true;587 expect(acaFees == 0n).to.be.true;
588
589 const bigintAbs = (n: bigint) => (n < 0n) ? -n : n;
590
586 expect(591 expect(
587 acaUnqFees == expectedAcalaIncomeFee,592 bigintAbs(acaUnqFees - expectedAcalaIncomeFee) < acalaEps,
588 'Acala took different income fee, check the Acala foreign asset config',593 'Acala took different income fee, check the Acala foreign asset config',
589 ).to.be.true;594 ).to.be.true;
590 });595 });
593 itSub('Should connect to Acala and send UNQ back', async ({helper}) => {598 itSub('Should connect to Acala and send UNQ back', async ({helper}) => {
594 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {599 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {
595 const destination = {600 const destination = {
596 V1: {601 V2: {
597 parents: 1,602 parents: 1,
598 interior: {603 interior: {
599 X2: [604 X2: [
613 ForeignAsset: 0,618 ForeignAsset: 0,
614 };619 };
615620
616 await helper.xTokens.transfer(randomAccount, id, ACALA_BACKWARD_TRANSFER_AMOUNT, destination, 'Unlimited');621 await helper.xTokens.transfer(randomAccount, id, acalaBackwardTransferAmount, destination, 'Unlimited');
617 balanceAcalaTokenFinal = await helper.balance.getSubstrate(randomAccount.address);622 balanceAcalaTokenFinal = await helper.balance.getSubstrate(randomAccount.address);
618 balanceUniqueForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);623 balanceUniqueForeignTokenFinal = await helper.tokens.accounts(randomAccount.address, id);
619624
627 console.log('[Acala -> Unique] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));632 console.log('[Acala -> Unique] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));
628633
629 expect(acaFees > 0, 'Negative fees ACA, looks like nothing was transferred').to.be.true;634 expect(acaFees > 0, 'Negative fees ACA, looks like nothing was transferred').to.be.true;
630 expect(unqOutcomeTransfer == ACALA_BACKWARD_TRANSFER_AMOUNT).to.be.true;635 expect(unqOutcomeTransfer == acalaBackwardTransferAmount).to.be.true;
631 });636 });
632637
633 await helper.wait.newBlocks(3);638 await helper.wait.newBlocks(3);
638643
639 console.log('[Acala -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));644 console.log('[Acala -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));
640645
641 const unqFees = ACALA_BACKWARD_TRANSFER_AMOUNT - actuallyDelivered;646 const unqFees = acalaBackwardTransferAmount - actuallyDelivered;
642 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));647 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));
643 expect(unqFees == 0n).to.be.true;648 expect(unqFees == 0n).to.be.true;
644 });649 });
655 const [targetAccount] = await helper.arrange.createAccounts([targetAccountBalance], alice);660 const [targetAccount] = await helper.arrange.createAccounts([targetAccountBalance], alice);
656661
657 const uniqueMultilocation = {662 const uniqueMultilocation = {
658 V1: {663 V2: {
659 parents: 1,664 parents: 1,
660 interior: {665 interior: {
661 X1: {Parachain: UNIQUE_CHAIN},666 X1: {Parachain: UNIQUE_CHAIN},
685 });690 });
686691
687 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash692 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash
688 && event.outcome().isFailedToTransactAsset);693 && event.outcome.isFailedToTransactAsset);
689694
690 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);695 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
691 expect(targetAccountBalance).to.be.equal(0n);696 expect(targetAccountBalance).to.be.equal(0n);
718 const [targetAccount] = await helper.arrange.createAccounts([0n], alice);723 const [targetAccount] = await helper.arrange.createAccounts([0n], alice);
719724
720 const uniqueMultilocation = {725 const uniqueMultilocation = {
721 V1: {726 V2: {
722 parents: 1,727 parents: 1,
723 interior: {728 interior: {
724 X1: {729 X1: {
766 });771 });
767772
768 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash773 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
769 && event.outcome().isUntrustedReserveLocation);774 && event.outcome.isUntrustedReserveLocation);
770775
771 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);776 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
772 expect(accountBalance).to.be.equal(0n);777 expect(accountBalance).to.be.equal(0n);
779 });784 });
780785
781 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash786 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
782 && event.outcome().isUntrustedReserveLocation);787 && event.outcome.isUntrustedReserveLocation);
783788
784 accountBalance = await helper.balance.getSubstrate(targetAccount.address);789 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
785 expect(accountBalance).to.be.equal(0n);790 expect(accountBalance).to.be.equal(0n);
845 };850 };
846851
847 uniqueCombinedMultilocationAcala = {852 uniqueCombinedMultilocationAcala = {
848 V1: {853 V2: {
849 parents: 1,854 parents: 1,
850 interior: {855 interior: {
851 X2: [uniqueParachainJunction, uniqueAccountJunction],856 X2: [uniqueParachainJunction, uniqueAccountJunction],
865870
866 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {871 const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
867 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash872 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == messageSent.messageHash
868 && event.outcome().isFailedToTransactAsset);873 && event.outcome.isFailedToTransactAsset);
869 };874 };
870875
871 itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {876 itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {
1178 });1183 });
11791184
1180 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash1185 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash
1181 && event.outcome().isFailedToTransactAsset);1186 && event.outcome.isFailedToTransactAsset);
11821187
1183 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1188 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1184 expect(targetAccountBalance).to.be.equal(0n);1189 expect(targetAccountBalance).to.be.equal(0n);
1267 });1272 });
12681273
1269 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash1274 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
1270 && event.outcome().isUntrustedReserveLocation);1275 && event.outcome.isUntrustedReserveLocation);
12711276
1272 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1277 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1273 expect(accountBalance).to.be.equal(0n);1278 expect(accountBalance).to.be.equal(0n);
1284 });1289 });
12851290
1286 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash1291 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
1287 && event.outcome().isUntrustedReserveLocation);1292 && event.outcome.isUntrustedReserveLocation);
12881293
1289 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1294 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1290 expect(accountBalance).to.be.equal(0n);1295 expect(accountBalance).to.be.equal(0n);
1543 });1548 });
15441549
1545 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash1550 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramSent.messageHash
1546 && event.outcome().isFailedToTransactAsset);1551 && event.outcome.isFailedToTransactAsset);
15471552
1548 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);1553 targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
1549 expect(targetAccountBalance).to.be.equal(0n);1554 expect(targetAccountBalance).to.be.equal(0n);
1624 });1629 });
16251630
1626 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash1631 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramFullIdSent.messageHash
1627 && event.outcome().isUntrustedReserveLocation);1632 && event.outcome.isUntrustedReserveLocation);
16281633
1629 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);1634 let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1630 expect(accountBalance).to.be.equal(0n);1635 expect(accountBalance).to.be.equal(0n);
1637 });1642 });
16381643
1639 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash1644 await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash == maliciousXcmProgramHereIdSent.messageHash
1640 && event.outcome().isUntrustedReserveLocation);1645 && event.outcome.isUntrustedReserveLocation);
16411646
1642 accountBalance = await helper.balance.getSubstrate(targetAccount.address);1647 accountBalance = await helper.balance.getSubstrate(targetAccount.address);
1643 expect(accountBalance).to.be.equal(0n);1648 expect(accountBalance).to.be.equal(0n);