difftreelog
Add Quartz-Shiden tests
in: master
+ fix send-back test
2 files changed
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth18import {blake2AsHex} from '@polkadot/util-crypto';18import {blake2AsHex} from '@polkadot/util-crypto';19import config from '../config';19import config from '../config';20import {XcmV2TraitsError} from '../interfaces';20import {XcmV2TraitsError} from '../interfaces';21import {itSub, expect, describeXCM, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds, usingStateminePlaygrounds} from '../util';21import {itSub, expect, describeXCM, usingPlaygrounds, usingKaruraPlaygrounds, usingRelayPlaygrounds, usingMoonriverPlaygrounds, usingStateminePlaygrounds, usingAstarPlaygrounds} from '../util';222223const QUARTZ_CHAIN = 2095;23const QUARTZ_CHAIN = 2095;24const STATEMINE_CHAIN = 1000;24const STATEMINE_CHAIN = 1000;25const KARURA_CHAIN = 2000;25const KARURA_CHAIN = 2000;26const MOONRIVER_CHAIN = 2023;26const MOONRIVER_CHAIN = 2023;27const SHIDEN_CHAIN = 2007;272828const STATEMINE_PALLET_INSTANCE = 50;29const STATEMINE_PALLET_INSTANCE = 50;293030const relayUrl = config.relayUrl;31const relayUrl = config.relayUrl;31const statemineUrl = config.statemineUrl;32const statemineUrl = config.statemineUrl;32const karuraUrl = config.karuraUrl;33const karuraUrl = config.karuraUrl;33const moonriverUrl = config.moonriverUrl;34const moonriverUrl = config.moonriverUrl;35const shidenUrl = config.shidenUrl;343635const RELAY_DECIMALS = 12;37const RELAY_DECIMALS = 12;36const STATEMINE_DECIMALS = 12;38const STATEMINE_DECIMALS = 12;979 });981 });980});982});983984describeXCM('[XCM] Integration test: Exchanging tokens with Shiden', () => {985 let alice: IKeyringPair;986 let randomAccount: IKeyringPair;987988 const shidenInitialBalance = 1n * (10n ** 18n);989 const qtzToShidenAmount = 10n * (10n ** 18n);990991 before(async () => {992 await usingPlaygrounds(async (helper, privateKey) => {993 alice = await privateKey('//Alice');994 [randomAccount] = await helper.arrange.createAccounts([100n], alice);995 console.log('randomAccount', randomAccount.address);996 });997998 await usingAstarPlaygrounds(shidenUrl, async (helper) => {999 console.log('1. Create foreign asset and metadata');1000 await helper.assets.create(1001 alice,1002 1,1003 alice.address,1004 1n,1005 );10061007 await helper.assets.setMetadata(1008 alice,1009 1,1010 'Cross chain QTZ',1011 'xcQTZ',1012 18,1013 );10141015 console.log('2. Register asset location');1016 const assetLocation = {1017 V1: {1018 parents: 1,1019 interior: {1020 X1: {1021 Parachain: QUARTZ_CHAIN,1022 },1023 },1024 },1025 };10261027 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.registerAssetLocation', [assetLocation, 1]);10281029 console.log('3. Set payment for computation');1030 // TODO this is Phala's price, what price will be for Unique?1031 const unitsPerSecond = 228_000_000_000n;1032 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);10331034 console.log('4. Transfer 1 SDN to recepient');1035 await helper.balance.transferToSubstrate(alice, randomAccount.address, shidenInitialBalance);1036 });1037 });10381039 itSub.only('Should connect and send QTZ to Shiden', async ({helper}) => {1040 const destination = {1041 V1: {1042 parents: 1,1043 interior: {1044 X1: {1045 Parachain: SHIDEN_CHAIN,1046 },1047 },1048 },1049 };10501051 const beneficiary = {1052 V1: {1053 parents: 0,1054 interior: {1055 X1: {1056 AccountId32: {1057 network: 'Any',1058 id: randomAccount.addressRaw,1059 },1060 },1061 },1062 },1063 };10641065 const assets = {1066 V1: [1067 {1068 id: {1069 Concrete: {1070 parents: 0,1071 interior: 'Here',1072 },1073 },1074 fun: {1075 Fungible: qtzToShidenAmount,1076 },1077 },1078 ],1079 };10801081 // Initial balance is 100 UNQ1082 expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(100n * (10n ** 18n));10831084 const feeAssetItem = 0;1085 await helper.xcm.limitedReserveTransferAssets(randomAccount, destination, beneficiary, assets, feeAssetItem, 'Unlimited');10861087 // Balance after reserve transfer is less than 901088 expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(89_941967662676666465n);10891090 await usingAstarPlaygrounds(shidenUrl, async (helper) => {1091 await helper.wait.newBlocks(3);1092 const xcUNQbalance = await helper.assets.account(1, randomAccount.address);1093 const astarBalance = await helper.balance.getSubstrate(randomAccount.address);10941095 expect(xcUNQbalance).to.eq(9_999_999_999_088_000_000n);1096 // Astar balance does not changed1097 expect(astarBalance).to.eq(1_000_000_000_000_000_000n);1098 });1099 });11001101 itSub.only('Should connect to Shiden and send QTZ back', async ({helper}) => {1102 await usingAstarPlaygrounds(shidenUrl, async (helper) => {1103 const destination = {1104 V1: {1105 parents: 1,1106 interior: {1107 X1: {1108 Parachain: QUARTZ_CHAIN,1109 },1110 },1111 },1112 };11131114 const beneficiary = {1115 V1: {1116 parents: 0,1117 interior: {1118 X1: {1119 AccountId32: {1120 network: 'Any',1121 id: randomAccount.addressRaw,1122 },1123 },1124 },1125 },1126 };11271128 const assets = {1129 V1: [1130 {1131 id: {1132 Concrete: {1133 parents: 1,1134 interior: {1135 X1: {1136 Parachain: QUARTZ_CHAIN,1137 },1138 },1139 },1140 },1141 fun: {1142 Fungible: 5_000_000_000_000_000_000n,1143 },1144 },1145 ],1146 };11471148 // Initial balance is 1 SDN1149 expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(1_000_000_000_000_000_000n);11501151 const feeAssetItem = 0;1152 await helper.executeExtrinsic(randomAccount, 'api.tx.polkadotXcm.reserveWithdrawAssets', [destination, beneficiary, assets, feeAssetItem]);11531154 // Balance after reserve transfer is less than 1 SDN1155 const xcUNQbalance = await helper.assets.account(1, randomAccount.address);1156 const balanceSDN = await helper.balance.getSubstrate(randomAccount.address);11571158 // Assert: xcQTZ balance decreased1159 expect(xcUNQbalance).to.eq(4_999_999_999_088_000_000n);1160 // Assert: SDN balance is 0.996...1161 expect(balanceSDN / (10n ** 15n)).to.eq(996n);1162 });11631164 await helper.wait.newBlocks(3);1165 const balanceUNQ = await helper.balance.getSubstrate(randomAccount.address);1166 expect(balanceUNQ).to.eq(89_941967662676666465n + 5_000_000_000_000_000_000n);1167 });1168});9811169tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -1003,7 +1003,7 @@
alice,
1,
alice.address,
- 1n, // TODO set correct minimal balance
+ 1n,
);
await helper.assets.setMetadata(
@@ -1033,7 +1033,7 @@
const unitsPerSecond = 228_000_000_000n;
await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);
- console.log('4. Transfer 1 ASTAR for recepient');
+ console.log('4. Transfer 1 ASTR to recepient');
await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);
});
});
@@ -1141,6 +1141,73 @@
},
},
fun: {
+ Fungible: 5_000_000_000_000_000_000n,
+ },
+ },
+ ],
+ };
+
+ // Initial balance is 1 ASTR
+ expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(1_000_000_000_000_000_000n);
+
+ const feeAssetItem = 0;
+ await helper.executeExtrinsic(randomAccount, 'api.tx.polkadotXcm.reserveWithdrawAssets', [destination, beneficiary, assets, feeAssetItem]);
+
+ const xcUNQbalance = await helper.assets.account(1, randomAccount.address);
+ const balanceAstar = await helper.balance.getSubstrate(randomAccount.address);
+
+ // Assert: xcUNQ balance decreased
+ expect(xcUNQbalance).to.eq(4_999_999_999_088_000_000n);
+ // Assert: ASTR balance is 0.996...
+ expect(balanceAstar / (10n ** 15n)).to.eq(996n);
+ });
+
+ await helper.wait.newBlocks(3);
+ const balanceUNQ = await helper.balance.getSubstrate(randomAccount.address);
+ expect(balanceUNQ).to.eq(89_941967662676666465n + 5_000_000_000_000_000_000n);
+ });
+
+ itSub.skip('Should not accept limitedReserveTransfer of UNQ from ASTAR', async ({helper}) => {
+ await usingAstarPlaygrounds(astarUrl, async (helper) => {
+ const destination = {
+ V1: {
+ parents: 1,
+ interior: {
+ X1: {
+ Parachain: UNIQUE_CHAIN,
+ },
+ },
+ },
+ };
+
+ const beneficiary = {
+ V1: {
+ parents: 0,
+ interior: {
+ X1: {
+ AccountId32: {
+ network: 'Any',
+ id: randomAccount.addressRaw,
+ },
+ },
+ },
+ },
+ };
+
+ const assets = {
+ V1: [
+ {
+ id: {
+ Concrete: {
+ parents: 1,
+ interior: {
+ X1: {
+ Parachain: UNIQUE_CHAIN,
+ },
+ },
+ },
+ },
+ fun: {
Fungible: 5_000_000_000_000_000_000n, // TODO set another value
},
},