From bf405ef96b1568557f9891a5e9c8a290bf5de3bf Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 02 Mar 2022 06:11:01 +0000 Subject: [PATCH] CORE-215 Fix helpers: check same sender and recepient --- --- a/tests/src/transfer.test.ts +++ b/tests/src/transfer.test.ts @@ -325,7 +325,7 @@ expect(balanceAliceBefore).to.be.eq(balanceAliceAfter); }); - itWeb3.only('Transfers to self. In case of inside substrate-evm', async ({api}) => { + itWeb3('Transfers to self. In case of inside substrate-evm', async ({api}) => { const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); const alice = privateKey('//Alice'); const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address}); --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -26,6 +26,7 @@ } | { Ethereum: string, }; + export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId { if (typeof input === 'string') { if (input.length === 48 || input.length === 47) { @@ -752,6 +753,7 @@ type = 'NFT', ) { await usingApi(async (api: ApiPromise) => { + const from = normalizeAccountId(accountFrom); const to = normalizeAccountId(accountTo); let balanceBefore = 0n; if (type === 'Fungible') { @@ -767,7 +769,11 @@ } if (type === 'Fungible') { const balanceAfter = await getBalance(api, collectionId, to, tokenId); - expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value)); + if (JSON.stringify(to) !== JSON.stringify(from)) { + expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value)); + } else { + expect(balanceAfter).to.be.equal(balanceBefore); + } } if (type === 'ReFungible') { expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(BigInt(value)); @@ -866,6 +872,7 @@ type = 'NFT', ) { await usingApi(async (api: ApiPromise) => { + const from = normalizeAccountId(sender); const to = normalizeAccountId(recipient); let balanceBefore = 0n; @@ -887,7 +894,11 @@ } if (type === 'Fungible') { const balanceAfter = await getBalance(api, collectionId, to, tokenId); - expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value)); + if (JSON.stringify(to) !== JSON.stringify(from)) { + expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value)); + } else { + expect(balanceAfter).to.be.equal(balanceBefore); + } } if (type === 'ReFungible') { expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true; -- gitstuff