git.delta.rocks / unique-network / refs/commits / 3ad5f43433c5

difftreelog

fix Opal send relay tokens back

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

1 file changed

modifiedtests/src/xcm/xcmOpal.test.tsdiffbeforeafterboth
31const ASSET_METADATA_DESCRIPTION = 'USDT';31const ASSET_METADATA_DESCRIPTION = 'USDT';
32const ASSET_METADATA_MINIMAL_BALANCE = 1n;32const ASSET_METADATA_MINIMAL_BALANCE = 1n;
3333
34const RELAY_DECIMALS = 12;
34const WESTMINT_DECIMALS = 12;35const WESTMINT_DECIMALS = 12;
3536
36const TRANSFER_AMOUNT = 1_000_000_000_000_000_000n;37const TRANSFER_AMOUNT = 1_000_000_000_000_000_000n;
209210
210 // common good parachain take commission in it native token211 // common good parachain take commission in it native token
211 console.log(212 console.log(
212 'Opal to Westmint transaction fees on Westmint: %s WND',213 '[Westmint -> Opal] transaction fees on Westmint: %s WND',
213 helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, WESTMINT_DECIMALS),214 helper.util.bigIntToDecimals(balanceStmnBefore - balanceStmnAfter, WESTMINT_DECIMALS),
214 );215 );
215 expect(balanceStmnBefore > balanceStmnAfter).to.be.true;216 expect(balanceStmnBefore > balanceStmnAfter).to.be.true;
226 balanceOpalAfter = await helper.balance.getSubstrate(alice.address);227 balanceOpalAfter = await helper.balance.getSubstrate(alice.address);
227228
228 console.log(229 console.log(
229 'Opal to Westmint transaction fees on Opal: %s USDT',230 '[Westmint -> Opal] transaction fees on Opal: %s USDT',
230 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, ASSET_METADATA_DECIMALS),231 helper.util.bigIntToDecimals(TRANSFER_AMOUNT - free, ASSET_METADATA_DECIMALS),
231 );232 );
232 console.log(233 console.log(
233 'Opal to Westmint transaction fees on Opal: %s OPL',234 '[Westmint -> Opal] transaction fees on Opal: %s OPL',
234 helper.util.bigIntToDecimals(balanceOpalAfter - balanceOpalBefore),235 helper.util.bigIntToDecimals(balanceOpalAfter - balanceOpalBefore),
235 );236 );
236237
360 });361 });
361362
362 itSub('Should connect and send Relay token back', async ({helper}) => {363 itSub('Should connect and send Relay token back', async ({helper}) => {
364 let relayTokenBalanceBefore: bigint;
365 let relayTokenBalanceAfter: bigint;
366 await usingRelayPlaygrounds(relayUrl, async (helper) => {
367 relayTokenBalanceBefore = await helper.balance.getSubstrate(bob.address);
368 });
369
363 const destination = {370 const destination = {
364 V1: {371 V1: {
365 parents: 1,372 parents: 1,
366 interior: {X2: [373 interior: {
367 {
368 Parachain: STATEMINE_CHAIN,
369 },
370 {374 X1:{
371 AccountId32: {375 AccountId32: {
372 network: 'Any',376 network: 'Any',
373 id: bob.addressRaw,377 id: bob.addressRaw,
374 },378 },
375 },379 },
376 ]},380 },
377 },381 },
378 };382 };
379383
391 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, {Unlimited: null});395 await helper.xTokens.transferMulticurrencies(bob, currencies, feeItem, destination, {Unlimited: null});
392396
393 balanceBobFinal = await helper.balance.getSubstrate(bob.address);397 balanceBobFinal = await helper.balance.getSubstrate(bob.address);
394 console.log('Relay (Westend) to Opal transaction fees: %s OPL', balanceBobAfter - balanceBobFinal);398 console.log('[Opal -> Relay (Westend)] transaction fees: %s OPL', helper.util.bigIntToDecimals(balanceBobAfter - balanceBobFinal));
399
400 await usingRelayPlaygrounds(relayUrl, async (helper) => {
401 await helper.wait.newBlocks(10);
402 relayTokenBalanceAfter = await helper.balance.getSubstrate(bob.address);
403
404 const diff = relayTokenBalanceAfter - relayTokenBalanceBefore;
405 console.log('[Opal -> Relay (Westend)] actually delivered: %s WND', helper.util.bigIntToDecimals(diff, RELAY_DECIMALS));
406 expect(diff > 0, 'Relay tokens was not delivered back').to.be.true;
407 });
395 });408 });
396});409});
397410