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.tsdiffbeforeafterboth1003 alice,1003 alice,1004 1,1004 1,1005 alice.address,1005 alice.address,1006 1n, // TODO set correct minimal balance1006 1n,1007 );1007 );100810081009 await helper.assets.setMetadata(1009 await helper.assets.setMetadata(1033 const unitsPerSecond = 228_000_000_000n;1033 const unitsPerSecond = 228_000_000_000n;1034 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);1034 await helper.getSudo().executeExtrinsic(alice, 'api.tx.xcAssetConfig.setAssetUnitsPerSecond', [assetLocation, unitsPerSecond]);103510351036 console.log('4. Transfer 1 ASTAR for recepient');1036 console.log('4. Transfer 1 ASTR to recepient');1037 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);1037 await helper.balance.transferToSubstrate(alice, randomAccount.address, astarInitialBalance);1038 });1038 });1039 });1039 });1100 });1100 });1101 });1101 });11021103 itSub.only('Should connect to Astar and send UNQ back', async ({helper}) => {1104 await usingAstarPlaygrounds(astarUrl, async (helper) => {1105 const destination = {1106 V1: {1107 parents: 1,1108 interior: {1109 X1: {1110 Parachain: UNIQUE_CHAIN,1111 },1112 },1113 },1114 };11151116 const beneficiary = {1117 V1: {1118 parents: 0,1119 interior: {1120 X1: {1121 AccountId32: {1122 network: 'Any',1123 id: randomAccount.addressRaw,1124 },1125 },1126 },1127 },1128 };11291130 const assets = {1131 V1: [1132 {1133 id: {1134 Concrete: {1135 parents: 1,1136 interior: {1137 X1: {1138 Parachain: UNIQUE_CHAIN,1139 },1140 },1141 },1142 },1143 fun: {1144 Fungible: 5_000_000_000_000_000_000n,1145 },1146 },1147 ],1148 };11491150 // Initial balance is 1 ASTR1151 expect(await helper.balance.getSubstrate(randomAccount.address)).to.eq(1_000_000_000_000_000_000n);11521153 const feeAssetItem = 0;1154 await helper.executeExtrinsic(randomAccount, 'api.tx.polkadotXcm.reserveWithdrawAssets', [destination, beneficiary, assets, feeAssetItem]);11551156 const xcUNQbalance = await helper.assets.account(1, randomAccount.address);1157 const balanceAstar = await helper.balance.getSubstrate(randomAccount.address);11581159 // Assert: xcUNQ balance decreased1160 expect(xcUNQbalance).to.eq(4_999_999_999_088_000_000n);1161 // Assert: ASTR balance is 0.996...1162 expect(balanceAstar / (10n ** 15n)).to.eq(996n);1163 });11641165 await helper.wait.newBlocks(3);1166 const balanceUNQ = await helper.balance.getSubstrate(randomAccount.address);1167 expect(balanceUNQ).to.eq(89_941967662676666465n + 5_000_000_000_000_000_000n);1168 });110211691103 itSub.only('Should connect to Astar and send UNQ back', async ({helper}) => {1170 itSub.skip('Should not accept limitedReserveTransfer of UNQ from ASTAR', async ({helper}) => {1104 await usingAstarPlaygrounds(astarUrl, async (helper) => {1171 await usingAstarPlaygrounds(astarUrl, async (helper) => {1105 const destination = {1172 const destination = {1106 V1: {1173 V1: {