difftreelog
fix remove deprecated helpers from unique xcm test
in: master
1 file changed
tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {Keyring} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';19import {generateKeyringPair, bigIntToDecimals} from '../deprecated-helpers/helpers';20import {blake2AsHex} from '@polkadot/util-crypto';18import {blake2AsHex} from '@polkadot/util-crypto';21import {XcmV2TraitsError, XcmV2TraitsOutcome} from '../interfaces';19import {XcmV2TraitsError, XcmV2TraitsOutcome} from '../interfaces';22import {itSub, expect, describeXcm, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds} from '../util/playgrounds';20import {itSub, expect, describeXcm, usingPlaygrounds, usingAcalaPlaygrounds, usingRelayPlaygrounds, usingMoonbeamPlaygrounds} from '../util/playgrounds';52 let balanceUniqueForeignTokenFinal: bigint;50 let balanceUniqueForeignTokenFinal: bigint;535154 before(async () => {52 before(async () => {55 await usingPlaygrounds(async (_helper, privateKey) => {53 await usingPlaygrounds(async (helper, privateKey) => {56 const keyringSr25519 = new Keyring({type: 'sr25519'});5758 alice = privateKey('//Alice');54 alice = privateKey('//Alice');59 randomAccount = generateKeyringPair(keyringSr25519);55 [randomAccount] = await helper.arrange.createAccounts([0n], alice);60 });56 });615762 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {58 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {138 balanceUniqueTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);134 balanceUniqueTokenMiddle = await helper.balance.getSubstrate(randomAccount.address);139135140 const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;136 const unqFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;141 console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));137 console.log('[Unique -> Acala] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));142 expect(unqFees > 0n).to.be.true;138 expect(unqFees > 0n).to.be.true;143139144 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {140 await usingAcalaPlaygrounds(acalaUrl, async (helper) => {152148153 console.log(149 console.log(154 '[Unique -> Acala] transaction fees on Acala: %s ACA',150 '[Unique -> Acala] transaction fees on Acala: %s ACA',155 bigIntToDecimals(acaFees, ACALA_DECIMALS),151 helper.util.bigIntToDecimals(acaFees, ACALA_DECIMALS),156 );152 );157 console.log('[Unique -> Acala] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));153 console.log('[Unique -> Acala] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));158 expect(acaFees == 0n).to.be.true;154 expect(acaFees == 0n).to.be.true;159 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;155 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;160 });156 });195191196 console.log(192 console.log(197 '[Acala -> Unique] transaction fees on Acala: %s ACA',193 '[Acala -> Unique] transaction fees on Acala: %s ACA',198 bigIntToDecimals(acaFees, ACALA_DECIMALS),194 helper.util.bigIntToDecimals(acaFees, ACALA_DECIMALS),199 );195 );200 console.log('[Acala -> Unique] outcome %s UNQ', bigIntToDecimals(unqOutcomeTransfer));196 console.log('[Acala -> Unique] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));201197202 expect(acaFees > 0).to.be.true;198 expect(acaFees > 0).to.be.true;203 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;199 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;209 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;205 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;210 expect(actuallyDelivered > 0).to.be.true;206 expect(actuallyDelivered > 0).to.be.true;211207212 console.log('[Acala -> Unique] actually delivered %s UNQ', bigIntToDecimals(actuallyDelivered));208 console.log('[Acala -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));213209214 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;210 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;215 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));211 console.log('[Acala -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));216 expect(unqFees == 0n).to.be.true;212 expect(unqFees == 0n).to.be.true;217 });213 });218});214});343 });339 });344});340});345341346describe.only('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {342describeXcm('[XCM] Integration test: Exchanging UNQ with Moonbeam', () => {347343348 // Unique constants344 // Unique constants349 let uniqueAlice: IKeyringPair;345 let uniqueDonor: IKeyringPair;350 let uniqueAssetLocation;346 let uniqueAssetLocation;351347352 let randomAccountUnique: IKeyringPair;348 let randomAccountUnique: IKeyringPair;355 // Moonbeam constants351 // Moonbeam constants356 let assetId: string;352 let assetId: string;357358 const moonbeamKeyring = new Keyring({type: 'ethereum'});359 const alithPrivateKey = '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133';360 const baltatharPrivateKey = '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b';361 const dorothyPrivateKey = '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68';362363 const alithAccount = moonbeamKeyring.addFromUri(alithPrivateKey, undefined, 'ethereum');364 const baltatharAccount = moonbeamKeyring.addFromUri(baltatharPrivateKey, undefined, 'ethereum');365 const dorothyAccount = moonbeamKeyring.addFromUri(dorothyPrivateKey, undefined, 'ethereum');366353367 const councilVotingThreshold = 2;354 const councilVotingThreshold = 2;368 const technicalCommitteeThreshold = 2;355 const technicalCommitteeThreshold = 2;388 let balanceGlmrTokenFinal: bigint;375 let balanceGlmrTokenFinal: bigint;389376390 before(async () => {377 before(async () => {391 await usingPlaygrounds(async (_helper, privateKey) => {378 await usingPlaygrounds(async (helper, privateKey) => {392 const keyringEth = new Keyring({type: 'ethereum'});393 const keyringSr25519 = new Keyring({type: 'sr25519'});394395 uniqueAlice = privateKey('//Alice');379 uniqueDonor = privateKey('//Alice');396 randomAccountUnique = generateKeyringPair(keyringSr25519);380 [randomAccountUnique] = await helper.arrange.createAccounts([0n], uniqueDonor);397 randomAccountMoonbeam = generateKeyringPair(keyringEth);398381399 balanceForeignUnqTokenInit = 0n;382 balanceForeignUnqTokenInit = 0n;400 });383 });401384402 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {385 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {386 const alithAccount = helper.account.alithAccount();387 const baltatharAccount = helper.account.baltatharAccount();388 const dorothyAccount = helper.account.dorothyAccount();389390 randomAccountMoonbeam = helper.account.create();391403 // >>> Sponsoring Dorothy >>>392 // >>> Sponsoring Dorothy >>>404 console.log('Sponsoring Dorothy.......');393 console.log('Sponsoring Dorothy.......');502 });491 });503492504 await usingPlaygrounds(async (helper) => {493 await usingPlaygrounds(async (helper) => {505 await helper.balance.transferToSubstrate(uniqueAlice, randomAccountUnique.address, 10n * TRANSFER_AMOUNT);494 await helper.balance.transferToSubstrate(uniqueDonor, randomAccountUnique.address, 10n * TRANSFER_AMOUNT);506 balanceUniqueTokenInit = await helper.balance.getSubstrate(randomAccountUnique.address);495 balanceUniqueTokenInit = await helper.balance.getSubstrate(randomAccountUnique.address);507 });496 });508 });497 });531 expect(balanceUniqueTokenMiddle < balanceUniqueTokenInit).to.be.true;520 expect(balanceUniqueTokenMiddle < balanceUniqueTokenInit).to.be.true;532521533 const transactionFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;522 const transactionFees = balanceUniqueTokenInit - balanceUniqueTokenMiddle - TRANSFER_AMOUNT;534 console.log('[Unique -> Moonbeam] transaction fees on Unique: %s UNQ', bigIntToDecimals(transactionFees));523 console.log('[Unique -> Moonbeam] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(transactionFees));535 expect(transactionFees > 0).to.be.true;524 expect(transactionFees > 0).to.be.true;536525537 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {526 await usingMoonbeamPlaygrounds(moonbeamUrl, async (helper) => {540 balanceGlmrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonbeam.address);529 balanceGlmrTokenMiddle = await helper.balance.getEthereum(randomAccountMoonbeam.address);541530542 const glmrFees = balanceGlmrTokenInit - balanceGlmrTokenMiddle;531 const glmrFees = balanceGlmrTokenInit - balanceGlmrTokenMiddle;543 console.log('[Unique -> Moonbeam] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));532 console.log('[Unique -> Moonbeam] transaction fees on Moonbeam: %s GLMR', helper.util.bigIntToDecimals(glmrFees));544 expect(glmrFees == 0n).to.be.true;533 expect(glmrFees == 0n).to.be.true;545534546 balanceForeignUnqTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonbeam.address))!;535 balanceForeignUnqTokenMiddle = (await helper.assets.account(assetId, randomAccountMoonbeam.address))!;547536548 const unqIncomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenInit;537 const unqIncomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenInit;549 console.log('[Unique -> Moonbeam] income %s UNQ', bigIntToDecimals(unqIncomeTransfer));538 console.log('[Unique -> Moonbeam] income %s UNQ', helper.util.bigIntToDecimals(unqIncomeTransfer));550 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;539 expect(unqIncomeTransfer == TRANSFER_AMOUNT).to.be.true;551 });540 });552 });541 });586 balanceGlmrTokenFinal = await helper.balance.getEthereum(randomAccountMoonbeam.address);575 balanceGlmrTokenFinal = await helper.balance.getEthereum(randomAccountMoonbeam.address);587576588 const glmrFees = balanceGlmrTokenMiddle - balanceGlmrTokenFinal;577 const glmrFees = balanceGlmrTokenMiddle - balanceGlmrTokenFinal;589 console.log('[Moonbeam -> Unique] transaction fees on Moonbeam: %s GLMR', bigIntToDecimals(glmrFees));578 console.log('[Moonbeam -> Unique] transaction fees on Moonbeam: %s GLMR', helper.util.bigIntToDecimals(glmrFees));590 expect(glmrFees > 0).to.be.true;579 expect(glmrFees > 0).to.be.true;591580592 const unqRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonbeam.address);581 const unqRandomAccountAsset = await helper.assets.account(assetId, randomAccountMoonbeam.address);596 balanceForeignUnqTokenFinal = 0n;585 balanceForeignUnqTokenFinal = 0n;597586598 const unqOutcomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenFinal;587 const unqOutcomeTransfer = balanceForeignUnqTokenMiddle - balanceForeignUnqTokenFinal;599 console.log('[Unique -> Moonbeam] outcome %s UNQ', bigIntToDecimals(unqOutcomeTransfer));588 console.log('[Unique -> Moonbeam] outcome %s UNQ', helper.util.bigIntToDecimals(unqOutcomeTransfer));600 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;589 expect(unqOutcomeTransfer == TRANSFER_AMOUNT).to.be.true;601 });590 });602591606 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;595 const actuallyDelivered = balanceUniqueTokenFinal - balanceUniqueTokenMiddle;607 expect(actuallyDelivered > 0).to.be.true;596 expect(actuallyDelivered > 0).to.be.true;608597609 console.log('[Moonbeam -> Unique] actually delivered %s UNQ', bigIntToDecimals(actuallyDelivered));598 console.log('[Moonbeam -> Unique] actually delivered %s UNQ', helper.util.bigIntToDecimals(actuallyDelivered));610599611 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;600 const unqFees = TRANSFER_AMOUNT - actuallyDelivered;612 console.log('[Moonbeam -> Unique] transaction fees on Unique: %s UNQ', bigIntToDecimals(unqFees));601 console.log('[Moonbeam -> Unique] transaction fees on Unique: %s UNQ', helper.util.bigIntToDecimals(unqFees));613 expect(unqFees == 0n).to.be.true;602 expect(unqFees == 0n).to.be.true;614 });603 });615});604});