git.delta.rocks / unique-network / refs/commits / f9fd89d65b00

difftreelog

fix Quartz send relay tokens back

Daniel Shiposha2022-12-22parent: #09ca6c2.patch.diff
in: master

1 file changed

modifiedtests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth
32const karuraUrl = config.karuraUrl;32const karuraUrl = config.karuraUrl;
33const moonriverUrl = config.moonriverUrl;33const moonriverUrl = config.moonriverUrl;
3434
35const RELAY_DECIMALS = 12;
35const STATEMINE_DECIMALS = 12;36const STATEMINE_DECIMALS = 12;
36const KARURA_DECIMALS = 12;37const KARURA_DECIMALS = 12;
3738
243244
244 // common good parachain take commission in it native token245 // common good parachain take commission in it native token
245 console.log(246 console.log(
246 '[Quartz -> Statemine] transaction fees on Statemine: %s WND',247 '[Statemine -> Quartz] transaction fees on Statemine: %s WND',
247 helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, STATEMINE_DECIMALS),248 helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, STATEMINE_DECIMALS),
248 );249 );
249 expect(balanceStmnBefore > balanceStmnAfter).to.be.true;250 expect(balanceStmnBefore > balanceStmnAfter).to.be.true;
260 balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);261 balanceQuartzAfter = await helper.balance.getSubstrate(alice.address);
261262
262 console.log(263 console.log(
263 '[Quartz -> Statemine] transaction fees on Quartz: %s USDT',264 '[Statemine -> Quartz] transaction fees on Quartz: %s USDT',
264 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, USDT_ASSET_METADATA_DECIMALS),265 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, USDT_ASSET_METADATA_DECIMALS),
265 );266 );
266 console.log(267 console.log(
267 '[Quartz -> Statemine] transaction fees on Quartz: %s QTZ',268 '[Statemine -> Quartz] transaction fees on Quartz: %s QTZ',
268 helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore),269 helper.util.bigIntToDecimals(balanceQuartzAfter - balanceQuartzBefore),
269 ); 270 );
270 // commission has not paid in USDT token271 // commission has not paid in USDT token
313 314
314 // the commission has been paid in parachain native token315 // the commission has been paid in parachain native token
315 balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);316 balanceQuartzFinal = await helper.balance.getSubstrate(alice.address);
317 console.log('[Quartz -> Statemine] transaction fees on Quartz: %s QTZ', helper.util.bigIntToDecimals(balanceQuartzFinal - balanceQuartzAfter));
316 expect(balanceQuartzAfter > balanceQuartzFinal).to.be.true;318 expect(balanceQuartzAfter > balanceQuartzFinal).to.be.true;
317319
318 await usingStateminePlaygrounds(statemineUrl, async (helper) => {320 await usingStateminePlaygrounds(statemineUrl, async (helper) => {
377 balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});379 balanceBobRelayTokenAfter = await helper.tokens.accounts(bob.address, {NativeAssetId: 'Parent'});
378380
379 const wndFeeOnQuartz = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;381 const wndFeeOnQuartz = balanceBobRelayTokenAfter - TRANSFER_AMOUNT_RELAY - balanceBobRelayTokenBefore;
382 const wndDiffOnQuartz = balanceBobRelayTokenAfter - balanceBobRelayTokenBefore;
380 console.log(383 console.log(
381 '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',384 '[Relay (Westend) -> Quartz] transaction fees: %s QTZ',
382 helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),385 helper.util.bigIntToDecimals(balanceBobAfter - balanceBobBefore),
385 '[Relay (Westend) -> Quartz] transaction fees: %s WND',388 '[Relay (Westend) -> Quartz] transaction fees: %s WND',
386 helper.util.bigIntToDecimals(wndFeeOnQuartz, STATEMINE_DECIMALS),389 helper.util.bigIntToDecimals(wndFeeOnQuartz, STATEMINE_DECIMALS),
387 );390 );
391 console.log('[Relay (Westend) -> Quartz] actually delivered: %s WND', wndDiffOnQuartz);
388 expect(wndFeeOnQuartz == 0n, 'No incoming WND fees should be taken').to.be.true;392 expect(wndFeeOnQuartz == 0n, 'No incoming WND fees should be taken').to.be.true;
389 expect(balanceBobBefore == balanceBobAfter, 'No incoming QTZ fees should be taken').to.be.true;393 expect(balanceBobBefore == balanceBobAfter, 'No incoming QTZ fees should be taken').to.be.true;
390 expect(balanceBobRelayTokenBefore < balanceBobRelayTokenAfter).to.be.true;
391 });394 });
392395
393 itSub('Should connect and send Relay token back', async ({helper}) => {396 itSub('Should connect and send Relay token back', async ({helper}) => {
397 let relayTokenBalanceBefore: bigint;
398 let relayTokenBalanceAfter: bigint;
399 await usingRelayPlaygrounds(relayUrl, async (helper) => {
400 relayTokenBalanceBefore = await helper.balance.getSubstrate(bob.address);
401 });
402
394 const destination = {403 const destination = {
395 V1: {404 V1: {
396 parents: 1,405 parents: 1,
397 interior: {X2: [406 interior: {
398 {
399 Parachain: STATEMINE_CHAIN,
400 },
401 {407 X1:{
402 AccountId32: {408 AccountId32: {
403 network: 'Any',409 network: 'Any',
404 id: bob.addressRaw,410 id: bob.addressRaw,
405 },411 },
406 },412 },
407 ]},413 },
408 },414 },
409 };415 };
410416
422 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, {Unlimited: null});428 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, {Unlimited: null});
423429
424 balanceBobFinal = await helper.balance.getSubstrate(bob.address);430 balanceBobFinal = await helper.balance.getSubstrate(bob.address);
425 console.log('[Relay (Westend) to Quartz] transaction fees: %s QTZ', balanceBobAfter - balanceBobFinal);431 console.log('[Quartz -> Relay (Westend)] transaction fees: %s QTZ', helper.util.bigIntToDecimals(balanceBobAfter - balanceBobFinal));
432
433 await usingRelayPlaygrounds(relayUrl, async (helper) => {
434 await helper.wait.newBlocks(10);
435 relayTokenBalanceAfter = await helper.balance.getSubstrate(bob.address);
436
437 const diff = relayTokenBalanceAfter - relayTokenBalanceBefore;
438 console.log('[Quartz -> Relay (Westend)] actually delivered: %s WND', helper.util.bigIntToDecimals(diff, RELAY_DECIMALS));
439 expect(diff > 0, 'Relay tokens was not delivered back').to.be.true;
440 });
426 });441 });
427});442});
428443