From 3eee5dcd05c9208dd4d5b57b375ab1c757d6060c Mon Sep 17 00:00:00 2001 From: kozyrevdev <73348153+kozyrevdev@users.noreply.github.com> Date: Tue, 29 Mar 2022 10:49:04 +0000 Subject: [PATCH] Merge pull request #301 from UniqueNetwork/feature/CORE-215 CORE-215 Fix helpers: check same sender and recepient --- --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -37,6 +37,7 @@ } | { Ethereum: string, }; + export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId { if (typeof input === 'string') { if (input.length === 48 || input.length === 47) { @@ -763,6 +764,7 @@ type = 'NFT', ) { await usingApi(async (api: ApiPromise) => { + const from = normalizeAccountId(accountFrom); const to = normalizeAccountId(accountTo); let balanceBefore = 0n; if (type === 'Fungible') { @@ -778,7 +780,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)); @@ -877,6 +883,7 @@ type = 'NFT', ) { await usingApi(async (api: ApiPromise) => { + const from = normalizeAccountId(sender); const to = normalizeAccountId(recipient); let balanceBefore = 0n; @@ -898,7 +905,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