git.delta.rocks / unique-network / refs/commits / bf405ef96b15

difftreelog

CORE-215 Fix helpers: check same sender and recepient

Trubnikov Sergey2022-03-02parent: #980a35f.patch.diff
in: master

2 files changed

modifiedtests/src/transfer.test.tsdiffbeforeafterboth
325 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);325 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);
326 });326 });
327327
328 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});
modifiedtests/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;