difftreelog
CORE-215 Fix helpers: check same sender and recepient
in: master
2 files changed
tests/src/transfer.test.tsdiffbeforeafterboth325 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);325 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);326 });326 });327327328 itWeb3.only('Transfers to self. In case of inside substrate-evm', async ({api}) => {328 itWeb3('Transfers to self. In case of inside substrate-evm', async ({api}) => {329 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});329 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});330 const alice = privateKey('//Alice');330 const alice = privateKey('//Alice');331 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});331 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});tests/src/util/helpers.tsdiffbeforeafterboth--- 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;