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

difftreelog

Merge pull request #682 from UniqueNetwork/tests/require-await

Yaroslav Bolyukin2022-10-27parents: #1c71798 #0a94ed0.patch.diff
in: master
Add requireAwait rule to avoid flakiness in tests

25 files changed

modifiedtests/.eslintrc.jsondiffbeforeafterboth
--- a/tests/.eslintrc.json
+++ b/tests/.eslintrc.json
@@ -42,6 +42,7 @@
                 "avoidEscape": true
             }
         ],
+        "require-await": 2,
         "semi": [
             "error",
             "always"
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -56,10 +56,8 @@
     const collection = await helper.collection.getData(collectionId);
     expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));
 
-    const changeAdminTxBob = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address});
-    const changeAdminTxCharlie = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address});
-    await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);
-    await expect(changeAdminTxBob()).to.be.rejectedWith(/common\.NoPermission/);
+    await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);
+    await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.NoPermission/);
 
     const adminListAfterAddAdmin = await helper.collection.getAdmins(collectionId);
     expect(adminListAfterAddAdmin).to.be.not.deep.contains({Substrate: charlie.address});
@@ -75,8 +73,7 @@
     const adminListAfterAddAdmin = await collection.getAdmins();
     expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});
 
-    const changeAdminTxCharlie = async () => collection.addAdmin(bob, {Substrate: charlie.address});
-    await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);
+    await expect(collection.addAdmin(bob, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);
 
     const adminListAfterAddNewAdmin = await collection.getAdmins();
     expect(adminListAfterAddNewAdmin).to.be.deep.contains({Substrate: bob.address});
@@ -87,8 +84,7 @@
     const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
     const collectionId = (1 << 32) - 1;
 
-    const addAdminTx = async () => helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
-    await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
+    await expect(helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);
 
     // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
     await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
@@ -99,8 +95,7 @@
     const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
 
     await collection.burn(alice);
-    const addAdminTx = async () => collection.addAdmin(alice, {Substrate: bob.address});
-    await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
+    await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);
 
     // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
     await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
@@ -119,7 +114,6 @@
       expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});
     }
 
-    const addExtraAdminTx = async () => collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address});
-    await expect(addExtraAdminTx()).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);
+    await expect(collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address})).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);
   });
 });
modifiedtests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth
--- a/tests/src/adminTransferAndBurn.test.ts
+++ b/tests/src/adminTransferAndBurn.test.ts
@@ -36,8 +36,7 @@
     expect(limits.ownerCanTransfer).to.be.true;
 
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
-    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});
-    await expect(transferResult()).to.be.rejected;
+    await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address})).to.be.rejected;
 
     await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
     const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
@@ -52,9 +51,8 @@
     expect(limits.ownerCanTransfer).to.be.true;
 
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
-    const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);
 
-    await expect(burnTxFailed()).to.be.rejected;
+    await expect(helper.nft.burnToken(alice, collectionId, tokenId)).to.be.rejected;
 
     await helper.nft.burnToken(bob, collectionId, tokenId);
     const token = await helper.nft.getToken(collectionId, tokenId);
modifiedtests/src/allowLists.test.tsdiffbeforeafterboth
--- a/tests/src/allowLists.test.ts
+++ b/tests/src/allowLists.test.ts
@@ -30,7 +30,7 @@
     });
   });
 
-  describe('Positive', async () => {
+  describe('Positive', () => {
     itSub('Owner can add address to allow list', async ({helper}) => {
       const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
       // allow list does not need to be enabled to add someone in advance
@@ -58,7 +58,7 @@
     });
   });
 
-  describe('Negative', async () => {
+  describe('Negative', () => {
     itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {
       const collectionId = (1<<32) - 1;
       await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))
@@ -92,7 +92,7 @@
     });
   });
 
-  describe('Positive', async () => {
+  describe('Positive', () => {
     itSub('Owner can remove address from allow list', async ({helper}) => {
       const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
       await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});
@@ -128,7 +128,7 @@
     });
   });
 
-  describe('Negative', async () => {
+  describe('Negative', () => {
     itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {
       const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
       await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});
@@ -168,7 +168,7 @@
     });
   });
 
-  describe('Positive', async () => {
+  describe('Positive', () => {
     itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {
       const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
       const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
@@ -219,7 +219,7 @@
     });
   });
 
-  describe('Negative', async () => {
+  describe('Negative', () => {
     itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {
       const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
       const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
@@ -303,7 +303,7 @@
     {access: 'AllowList', mintMode: true},
   ];
 
-  const testPermissionSuite = async (permissions: ICollectionPermissions) => {
+  const testPermissionSuite = (permissions: ICollectionPermissions) => {
     const allowlistedMintingShouldFail = !permissions.mintMode!;
 
     const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;
@@ -323,8 +323,8 @@
     );
 
 
-    describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, async () => {
-      describe('Positive', async () => {
+    describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, () => {
+      describe('Positive', () => {
         itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {
           const collection = await helper.nft.mintCollection(alice, {});
           await collection.setPermissions(alice, permissions);
@@ -341,7 +341,7 @@
         if (!allowlistedMintingShouldFail) allowlistedMintingTest();
       });
 
-      describe('Negative', async () => {
+      describe('Negative', () => {
         itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {
           const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
           await collection.setPermissions(alice, permissions);
modifiedtests/src/approve.test.tsdiffbeforeafterboth
--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -92,7 +92,7 @@
   itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
-    const approveTokenTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
+    const approveTokenTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
     await expect(approveTokenTx()).to.be.rejected;
   });
 });
@@ -196,7 +196,7 @@
     await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
     const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
     expect(owner.Substrate).to.be.equal(alice.address);
-    const transferTokenFromTx = async () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
+    const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 
@@ -210,7 +210,7 @@
     const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
     expect(after - before).to.be.equal(BigInt(1));
 
-    const transferTokenFromTx = async () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
+    const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 
@@ -222,7 +222,7 @@
     await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
     const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
     expect(after - before).to.be.equal(BigInt(100));
-    const transferTokenFromTx = async () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
+    const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 });
@@ -277,7 +277,7 @@
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
     await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
-    const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
+    const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 
@@ -293,7 +293,7 @@
     const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
     expect(amountAfter).to.be.equal(BigInt(0));
 
-    const transferTokenFromTx = async () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
+    const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 
@@ -308,7 +308,7 @@
     const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
     expect(amountAfter).to.be.equal(BigInt(0));
 
-    const transferTokenFromTx = async () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
+    const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
     await expect(transferTokenFromTx()).to.be.rejected;
   });
 });
@@ -328,7 +328,7 @@
   itSub('1 for NFT', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
-    const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
+    const approveTx = () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
     await expect(approveTx()).to.be.rejected;
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
   });
@@ -337,14 +337,14 @@
     const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
     await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
     const tokenId = await helper.ft.getLastTokenId(collectionId);
-    const approveTx = async () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
+    const approveTx = () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
     const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
-    const approveTx = async () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
+    const approveTx = () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
     await expect(approveTx()).to.be.rejected;
   });
 });
@@ -483,7 +483,7 @@
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
     await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
-    const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
+    const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
     await expect(approveTx()).to.be.rejected;
   });
 });
@@ -502,59 +502,59 @@
 
   itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {
     const collectionId = 1 << 32 - 1;
-    const approveTx = async () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+    const approveTx = () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {
     const collectionId = 1 << 32 - 1;
-    const approveTx = async () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+    const approveTx = () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {
     const collectionId = 1 << 32 - 1;
-    const approveTx = async () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+    const approveTx = () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await helper.nft.burn(alice, collectionId);
-    const approveTx = async () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+    const approveTx = () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {
     const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await helper.ft.burn(alice, collectionId);
-    const approveTx = async () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+    const approveTx = () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {
     const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await helper.rft.burn(alice, collectionId);
-    const approveTx = async () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+    const approveTx = () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
     await expect(approveTx()).to.be.rejected;
   });
   
   itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const approveTx = async () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
+    const approveTx = () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {
     const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const approveTx = async () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
+    const approveTx = () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
-    const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+    const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
     await expect(approveTx()).to.be.rejected;
   });
 
@@ -562,14 +562,14 @@
     const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
     const tokenId = await helper.ft.getLastTokenId(collectionId);
-    const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+    const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
     await expect(approveTx()).to.be.rejected;
   });
 
   itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {
     const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
-    const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+    const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
     await expect(approveTx()).to.be.rejected;
   });
 
@@ -579,7 +579,7 @@
     await helper.rft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 100n);
     await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 100n);
 
-    const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
+    const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
     await expect(approveTx()).to.be.rejected;
   });
 
@@ -590,7 +590,7 @@
 
     await helper.ft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);
     await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 10n);
-    const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
+    const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
     await expect(approveTx()).to.be.rejected;
   });
 
@@ -599,7 +599,7 @@
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
     await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});
 
-    const approveTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
+    const approveTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
     await expect(approveTx()).to.be.rejected;
   });
 });
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -56,7 +56,7 @@
 
     await collection.changeOwner(alice, bob.address);
 
-    const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
+    const changeOwnerTx = () => collection.changeOwner(alice, alice.address);
     await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
 
     const afterChanging = await helper.collection.getData(collection.collectionId);
@@ -115,20 +115,20 @@
 
   itSub('Not owner can\'t change owner.', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
+    const changeOwnerTx = () => collection.changeOwner(bob, bob.address);
     await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
   itSub('Collection admin can\'t change owner.', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.addAdmin(alice, {Substrate: bob.address});
-    const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
+    const changeOwnerTx = () => collection.changeOwner(bob, bob.address);
     await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
   itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {
     const collectionId = (1 << 32) - 1;
-    const changeOwnerTx = async () => helper.collection.changeOwner(bob, collectionId, bob.address);
+    const changeOwnerTx = () => helper.collection.changeOwner(bob, collectionId, bob.address);
     await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
   });
 
@@ -136,15 +136,15 @@
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.changeOwner(alice, bob.address);
 
-    const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
+    const changeOwnerTx = () => collection.changeOwner(alice, alice.address);
     await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
 
     const afterChanging = await helper.collection.getData(collection.collectionId);
     expect(afterChanging?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(bob.address));
 
-    const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
-    const removeSponsorTx = async () => collection.removeSponsor(alice);
+    const setSponsorTx = () => collection.setSponsor(alice, charlie.address);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);
+    const removeSponsorTx = () => collection.removeSponsor(alice);
     await expect(setSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
     await expect(removeSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
@@ -157,13 +157,13 @@
       ownerCanTransfer: true,
     };
 
-    const setLimitsTx = async () => collection.setLimits(alice, limits);
+    const setLimitsTx = () => collection.setLimits(alice, limits);
     await expect(setLimitsTx()).to.be.rejectedWith(/common\.NoPermission/);
 
-    const setPermissionTx = async () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});
+    const setPermissionTx = () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});
     await expect(setPermissionTx()).to.be.rejectedWith(/common\.NoPermission/);
 
-    const burnTx = async () => collection.burn(alice);
+    const burnTx = () => collection.burn(alice);
     await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 });
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -119,7 +119,7 @@
     await token.transfer(alice, {Substrate: zeroBalance.address});
     const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
 
-    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});
+    const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});
     await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
     const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
 
@@ -137,7 +137,7 @@
     await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);
     const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
 
-    const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});
+    const transferTx = () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});
     await expect(transferTx()).to.be.rejected;
     const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
 
@@ -155,7 +155,7 @@
     await token.transfer(zeroBalance, {Substrate: alice.address});
 
     const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
-    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});
+    const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});
     await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
     const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
 
@@ -175,7 +175,7 @@
     await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
 
     const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
-    const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
+    const mintTx = () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
     await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');
     const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
 
@@ -199,21 +199,21 @@
 
   itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {
     const collectionId = (1 << 32) - 1;
-    const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);
+    const confirmSponsorshipTx = () => helper.collection.confirmSponsorship(bob, collectionId);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
   });
 
   itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.setSponsor(alice, bob.address);
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
   });
 
   itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.setSponsor(alice, bob.address);
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
   });
 
@@ -221,20 +221,20 @@
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.setSponsor(alice, bob.address);
     await collection.addAdmin(alice, {Substrate: charlie.address});
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
   });
 
   itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
   });
 
   itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.burn(alice);
-    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+    const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
     await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
   });
 
@@ -244,7 +244,7 @@
     await collection.confirmSponsorship(bob);
     const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});
     const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);
-    const transferTx = async () =>  token.transfer(senderZeroBalance, {Substrate: alice.address});
+    const transferTx = () =>  token.transfer(senderZeroBalance, {Substrate: alice.address});
     await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
     const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);
     expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -116,20 +116,20 @@
   });
 
   itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});
     await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
   });
   itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});
     await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
   });
   itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});
     await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
   });
   
   itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});
     await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
   });
 
@@ -139,7 +139,7 @@
     for (let i = 0; i < 65; i++) {
       props.push({key: `key${i}`, value: `value${i}`});
     }
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
     await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
   });
 
@@ -150,7 +150,7 @@
       props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});
     }
 
-    const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
+    const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
     await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
   });
 });
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -186,17 +186,17 @@
 
   itSub('Regular user cannot create new item in NFT collection', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});
+    const mintTx = () => collection.mintToken(bob, {Substrate: bob.address});
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
   itSub('Regular user cannot create new item in Fungible collection', async ({helper}) => {
     const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
-    const mintTx = async () => collection.mint(bob, 10n, {Substrate: bob.address});
+    const mintTx = () => collection.mint(bob, 10n, {Substrate: bob.address});
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
   itSub.ifWithPallets('Regular user cannot create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
     const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const mintTx = async () => collection.mintToken(bob, 100n, {Substrate: bob.address});
+    const mintTx = () => collection.mintToken(bob, 100n, {Substrate: bob.address});
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
 
@@ -204,7 +204,7 @@
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
       tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],
     });
-    const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
     await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
@@ -212,13 +212,13 @@
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
       tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
     });
-    const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
     await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
   itSub('Adding property without access rights', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
     await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
@@ -231,7 +231,7 @@
 
 
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);
+    const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, props);
     await expect(mintTx()).to.be.rejectedWith('Verification Error');
   });
 
@@ -242,7 +242,7 @@
         {key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},
       ],
     });
-    const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [
+    const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [
       {key: 'k1', value: 'vvvvvv'.repeat(5000)},
       {key: 'k2', value: 'vvv'.repeat(5000)},
     ]);
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -183,7 +183,7 @@
       {},
       {},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
 
@@ -198,7 +198,7 @@
       {value: 2n},
       {value: 3n},
     ];
-    const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});
+    const mintTx = () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
 
@@ -213,7 +213,7 @@
       {pieces: 1n},
       {pieces: 1n},
     ];
-    const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
   });
 
@@ -223,7 +223,7 @@
       {},
       {},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
   });
 
@@ -241,7 +241,7 @@
       {properties: [{key: 'data', value: 'B'.repeat(32769)}]},
       {properties: [{key: 'data', value: 'C'.repeat(32769)}]},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith('Verification Error');
   });
 
@@ -259,7 +259,7 @@
       {pieces: 10n, properties: [{key: 'data', value: 'B'.repeat(32769)}]},
       {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},
     ];
-    const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith('Verification Error');
   });
 
@@ -291,7 +291,7 @@
       {properties: [{key: 'data', value: 'A'}]},
       {properties: [{key: 'data', value: 'B'.repeat(32769)}]},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith('Verification Error');
   });
 
@@ -311,7 +311,7 @@
       {},
       {},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
   });
 
@@ -327,7 +327,7 @@
     const args = [
       {properties: [{key: 'data', value: 'A'}]},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
@@ -346,7 +346,7 @@
     const args = [
       {properties: [{key: 'data', value: 'A'}]},
     ];
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
   });
 
@@ -368,7 +368,7 @@
       {properties: prps},
     ];
 
-    const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+    const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
     await expect(mintTx()).to.be.rejectedWith('Verification Error');
   });
 });
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -69,7 +69,7 @@
   });
 });
 
-describe('ERC165 tests', async () => {
+describe('ERC165 tests', () => {
   // https://eips.ethereum.org/EIPS/eip-165
 
   let erc721MetadataCompatibleNftCollectionId: number;
modifiedtests/src/eth/nesting/nest.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -81,7 +81,7 @@
     });
   });
 
-  describe('Negative Test: EVM Nesting', async() => {
+  describe('Negative Test: EVM Nesting', () => {
     itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {
       const owner = await helper.eth.createAccountWithBalance(donor);
 
modifiedtests/src/eth/util/index.tsdiffbeforeafterboth
--- a/tests/src/eth/util/index.ts
+++ b/tests/src/eth/util/index.ts
@@ -58,7 +58,7 @@
   }
 };
   
-export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
   (opts.only ? it.only : 
     opts.skip ? it.skip : it)(name, async function() {
     await usingEthPlaygrounds(async (helper, privateKey) => {
@@ -71,7 +71,7 @@
   });
 }
 
-export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
   return itEth(name, cb, {requiredPallets: required, ...opts});
 }
 
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -188,7 +188,7 @@
     return {collectionId, collectionAddress, events};
   }
 
-  async createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
+  createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
     return this.createCollecion('createNFTCollection', signer, name, description, tokenPrefix);
   }
 
@@ -202,7 +202,7 @@
     return {collectionId, collectionAddress, events};
   }
 
-  async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {
+  createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {
     return this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);
   }
 
@@ -409,7 +409,7 @@
     return this.web3;
   }
 
-  async connectWeb3(wsEndpoint: string) {
+  connectWeb3(wsEndpoint: string) {
     if(this.web3 !== null) return;
     this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);
     this.web3 = new Web3(this.web3Provider);
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -86,15 +86,15 @@
     });
   });
 
-  itSub('Required pallets are present', async ({helper}) => {
+  itSub('Required pallets are present', ({helper}) => {
     expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets]);
   });
 
-  itSub('Governance and consensus pallets are present', async ({helper}) => {
+  itSub('Governance and consensus pallets are present', ({helper}) => {
     expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets]);
   });
 
-  itSub('No extra pallets are included', async ({helper}) => {
+  itSub('No extra pallets are included', ({helper}) => {
     expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());
   });
 });
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -19,7 +19,7 @@
 
 const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;
 
-describe('integration test: Refungible functionality:', async () => {
+describe('integration test: Refungible functionality:', () => {
   let donor: IKeyringPair;
   let alice: IKeyringPair;
   let bob: IKeyringPair;
modifiedtests/src/rmrk/addResource.seqtest.tsdiffbeforeafterboth
--- a/tests/src/rmrk/addResource.seqtest.ts
+++ b/tests/src/rmrk/addResource.seqtest.ts
@@ -112,7 +112,7 @@
     const resourcesInfo = [];
     const resourceNum = 4;
 
-    const checkResource = async (resource: ResourceInfo, resType: string, expectedId: number, expected: {
+    const checkResource = (resource: ResourceInfo, resType: string, expectedId: number, expected: {
       src: string,
       metadata: string,
       license: string,
modifiedtests/src/rmrk/equipNft.seqtest.tsdiffbeforeafterboth
--- a/tests/src/rmrk/equipNft.seqtest.ts
+++ b/tests/src/rmrk/equipNft.seqtest.ts
@@ -30,7 +30,7 @@
 
 const slotId = 1;
 
-async function createTestCollection(api: ApiPromise): Promise<number> {
+function createTestCollection(api: ApiPromise): Promise<number> {
   return createCollection(
     api,
     alice,
@@ -60,7 +60,7 @@
   return nftChildId;
 }
 
-async function createTestBase(api: ApiPromise): Promise<number> {
+function createTestBase(api: ApiPromise): Promise<number> {
   return createBase(api, alice, 'test-base', 'DTBase', [
     {
       SlotPart: {
modifiedtests/src/rmrk/rmrkIsolation.seqtest.tsdiffbeforeafterboth
--- a/tests/src/rmrk/rmrkIsolation.seqtest.ts
+++ b/tests/src/rmrk/rmrkIsolation.seqtest.ts
@@ -58,7 +58,7 @@
   return rmrkNftId;
 }
 
-describe('RMRK External Integration Test', async () => {
+describe('RMRK External Integration Test', () => {
   before(async function() {
     await usingPlaygrounds(async (_helper, privateKey) => {
       alice = await privateKey('//Alice');
@@ -78,7 +78,7 @@
   });
 });
 
-describe('Negative Integration Test: External Collections, Internal Ops', async () => {
+describe('Negative Integration Test: External Collections, Internal Ops', () => {
   let uniqueCollectionId: number;
   let rmrkCollectionId: number;
   let rmrkNftId: number;
@@ -196,7 +196,7 @@
   });
 });
 
-describe('Negative Integration Test: Internal Collections, External Ops', async () => {
+describe('Negative Integration Test: Internal Collections, External Ops', () => {
   let collectionId: number;
   let nftId: number;
 
modifiedtests/src/rmrk/util/fetch.tsdiffbeforeafterboth
--- a/tests/src/rmrk/util/fetch.ts
+++ b/tests/src/rmrk/util/fetch.ts
@@ -20,7 +20,7 @@
   return (await api.rpc.rmrk.lastCollectionIdx()).toNumber();
 }
 
-export async function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {
+export function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {
   return api.rpc.rmrk.collectionById(id);
 }
 
@@ -36,7 +36,7 @@
     .map((value) => value.toNumber());
 }
 
-export async function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {
+export function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {
   return api.rpc.rmrk.nftById(collectionId, nftId);
 }
 
@@ -56,7 +56,7 @@
   return (await api.rpc.rmrk.nftChildren(collectionId, nftId)).toArray();
 }
 
-export async function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {
+export function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {
   return api.rpc.rmrk.base(baseId);
 }
 
@@ -112,7 +112,7 @@
     .map((name) => name.toUtf8());
 }
 
-export async function getTheme(
+export function getTheme(
   api: ApiPromise,
   baseId: number,
   themeName: string,
modifiedtests/src/tx-version-presence.test.tsdiffbeforeafterboth
--- a/tests/src/tx-version-presence.test.ts
+++ b/tests/src/tx-version-presence.test.ts
@@ -26,7 +26,7 @@
     });
   });
 
-  itSub('Signed extension CheckTxVersion is present', async () => {
+  itSub('Signed extension CheckTxVersion is present', () => {
     expect(metadata.asLatest.extrinsic.signedExtensions.map(se => se.identifier.toString())).to.include('CheckTxVersion');
   });
 });
modifiedtests/src/util/globalSetup.tsdiffbeforeafterboth
--- a/tests/src/util/globalSetup.ts
+++ b/tests/src/util/globalSetup.ts
@@ -90,7 +90,7 @@
   });
 };
 
-const fundFilenamesWithRetries = async (retriesLeft: number): Promise<boolean> => {
+const fundFilenamesWithRetries = (retriesLeft: number): Promise<boolean> => {
   if (retriesLeft <= 0) return Promise.resolve(false);
   return fundFilenames()
     .then(() => Promise.resolve(true))
modifiedtests/src/util/index.tsdiffbeforeafterboth
--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -59,27 +59,27 @@
   return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
 };
 
-export const usingWestmintPlaygrounds = async (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
 };
 
-export const usingRelayPlaygrounds = async (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
 };
 
-export const usingAcalaPlaygrounds = async (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
 };
 
-export const usingKaruraPlaygrounds = async (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
 };
 
-export const usingMoonbeamPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
 };
 
-export const usingMoonriverPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
   return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
 };
 
@@ -108,7 +108,7 @@
   }
 }
 
-export async function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
   (opts.only ? it.only : 
     opts.skip ? it.skip : it)(name, async function () {
     await usingPlaygrounds(async (helper, privateKey) => {
@@ -120,7 +120,7 @@
     });
   });
 }
-export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
   return itSub(name, cb, {requiredPallets: required, ...opts});
 }
 itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});
@@ -130,7 +130,7 @@
 itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});
 itSub.ifWithPallets = itSubIfWithPallet;
 
-export async function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {
+export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {
   (process.env.RUN_XCM_TESTS && !opts.skip
     ? describe
     : describe.skip)(title, fn);
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
before · tests/src/util/playgrounds/unique.dev.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {stringToU8a} from '@polkadot/util';5import {encodeAddress, mnemonicGenerate} from '@polkadot/util-crypto';6import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper} from './unique';7import {ApiPromise, Keyring, WsProvider} from '@polkadot/api';8import * as defs from '../../interfaces/definitions';9import {IKeyringPair} from '@polkadot/types/types';10import {EventRecord} from '@polkadot/types/interfaces';11import {ICrossAccountId, TSigner} from './types';12import {FrameSystemEventRecord} from '@polkadot/types/lookup';13import {VoidFn} from '@polkadot/api/types';14import {Pallets} from '..';1516export class SilentLogger {17  log(_msg: any, _level: any): void { }18  level = {19    ERROR: 'ERROR' as const,20    WARNING: 'WARNING' as const,21    INFO: 'INFO' as const,22  };23}2425export class SilentConsole {26  // TODO: Remove, this is temporary: Filter unneeded API output27  // (Jaco promised it will be removed in the next version)28  consoleErr: any;29  consoleLog: any;30  consoleWarn: any;3132  constructor() {33    this.consoleErr = console.error;34    this.consoleLog = console.log;35    this.consoleWarn = console.warn;36  }3738  enable() {  39    const outFn = (printer: any) => (...args: any[]) => {40      for (const arg of args) {41        if (typeof arg !== 'string')42          continue;43        if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')44          return;45      }46      printer(...args);47    };48  49    console.error = outFn(this.consoleErr.bind(console));50    console.log = outFn(this.consoleLog.bind(console));51    console.warn = outFn(this.consoleWarn.bind(console));52  }5354  disable() {55    console.error = this.consoleErr;56    console.log = this.consoleLog;57    console.warn = this.consoleWarn;58  }59}6061export class DevUniqueHelper extends UniqueHelper {62  /**63   * Arrange methods for tests64   */65  arrange: ArrangeGroup;66  wait: WaitGroup;67  admin: AdminGroup;68  testUtils: TestUtilGroup;6970  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {71    options.helperBase = options.helperBase ?? DevUniqueHelper;7273    super(logger, options);74    this.arrange = new ArrangeGroup(this);75    this.wait = new WaitGroup(this);76    this.admin = new AdminGroup(this);77    this.testUtils = new TestUtilGroup(this);78  }7980  async connect(wsEndpoint: string, _listeners?: any): Promise<void> {81    const wsProvider = new WsProvider(wsEndpoint);82    this.api = new ApiPromise({83      provider: wsProvider,84      signedExtensions: {85        ContractHelpers: {86          extrinsic: {},87          payload: {},88        },89        FakeTransactionFinalizer: {90          extrinsic: {},91          payload: {},92        },93      },94      rpc: {95        unique: defs.unique.rpc,96        appPromotion: defs.appPromotion.rpc,97        rmrk: defs.rmrk.rpc,98        eth: {99          feeHistory: {100            description: 'Dummy',101            params: [],102            type: 'u8',103          },104          maxPriorityFeePerGas: {105            description: 'Dummy',106            params: [],107            type: 'u8',108          },109        },110      },111    });112    await this.api.isReadyOrError;113    this.network = await UniqueHelper.detectNetwork(this.api);114  }115}116117export class DevRelayHelper extends RelayHelper {}118119export class DevWestmintHelper extends WestmintHelper {120  wait: WaitGroup;121122  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {123    options.helperBase = options.helperBase ?? DevWestmintHelper;124125    super(logger, options);126    this.wait = new WaitGroup(this);127  }128}129130export class DevMoonbeamHelper extends MoonbeamHelper {131  account: MoonbeamAccountGroup;132  wait: WaitGroup;133134  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {135    options.helperBase = options.helperBase ?? DevMoonbeamHelper;136137    super(logger, options);138    this.account = new MoonbeamAccountGroup(this);139    this.wait = new WaitGroup(this);140  }141}142143export class DevMoonriverHelper extends DevMoonbeamHelper {}144145export class DevAcalaHelper extends AcalaHelper {146  wait: WaitGroup;147148  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {149    options.helperBase = options.helperBase ?? DevAcalaHelper;150151    super(logger, options);152    this.wait = new WaitGroup(this);153  }154}155156export class DevKaruraHelper extends DevAcalaHelper {}157158class ArrangeGroup {159  helper: DevUniqueHelper;160161  scheduledIdSlider = 0;162163  constructor(helper: DevUniqueHelper) {164    this.helper = helper;165  }166167  /**168   * Generates accounts with the specified UNQ token balance 169   * @param balances balances for generated accounts. Each balance will be multiplied by the token nominal.170   * @param donor donor account for balances171   * @returns array of newly created accounts172   * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor); 173   */174  createAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {175    let nonce = await this.helper.chain.getNonce(donor.address);176    const wait = new WaitGroup(this.helper);177    const ss58Format = this.helper.chain.getChainProperties().ss58Format;178    const tokenNominal = this.helper.balance.getOneTokenNominal();179    const transactions = [];180    const accounts: IKeyringPair[] = [];181    for (const balance of balances) {182      const recipient = this.helper.util.fromSeed(mnemonicGenerate(), ss58Format);183      accounts.push(recipient);184      if (balance !== 0n) {185        const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recipient.address}, balance * tokenNominal]);186        transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));187        nonce++;188      }189    }190191    await Promise.all(transactions).catch(_e => {});192    193    //#region TODO remove this region, when nonce problem will be solved194    const checkBalances = async () => {195      let isSuccess = true;196      for (let i = 0; i < balances.length; i++) {197        const balance = await this.helper.balance.getSubstrate(accounts[i].address);198        if (balance !== balances[i] * tokenNominal) {199          isSuccess = false;200          break;201        }202      }203      return isSuccess;204    };205206    let accountsCreated = false;207    const maxBlocksChecked = await this.helper.arrange.isDevNode() ? 50 : 5;208    // checkBalances retry up to 5-50 blocks209    for (let index = 0; index < maxBlocksChecked; index++) {210      accountsCreated = await checkBalances();211      if(accountsCreated) break;212      await wait.newBlocks(1);213    }214215    if (!accountsCreated) throw Error('Accounts generation failed');216    //#endregion217218    return accounts;219  };220221  // TODO combine this method and createAccounts into one222  createCrowd = async (accountsToCreate: number, withBalance: bigint, donor: IKeyringPair): Promise<IKeyringPair[]> => {  223    const createAsManyAsCan = async () => {224      let transactions: any = [];225      const accounts: IKeyringPair[] = [];226      let nonce = await this.helper.chain.getNonce(donor.address);227      const tokenNominal = this.helper.balance.getOneTokenNominal();228      for (let i = 0; i < accountsToCreate; i++) {229        if (i === 500) { // if there are too many accounts to create230          await Promise.allSettled(transactions); // wait while first 500 (should be 100 for devnode) tx will be settled 231          transactions = []; //232          nonce = await this.helper.chain.getNonce(donor.address); // update nonce 233        }234        const recepient = this.helper.util.fromSeed(mnemonicGenerate());235        accounts.push(recepient);236        if (withBalance !== 0n) {237          const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recepient.address}, withBalance * tokenNominal]);238          transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));239          nonce++;240        }241      }242      243      const fullfilledAccounts = [];244      await Promise.allSettled(transactions);245      for (const account of accounts) {246        const accountBalance = await this.helper.balance.getSubstrate(account.address);247        if (accountBalance === withBalance * tokenNominal) {248          fullfilledAccounts.push(account);249        }250      }251      return fullfilledAccounts;252    };253254    255    const crowd: IKeyringPair[] = [];256    // do up to 5 retries257    for (let index = 0; index < 5 && accountsToCreate !== 0; index++) {258      const asManyAsCan = await createAsManyAsCan();259      crowd.push(...asManyAsCan);260      accountsToCreate -= asManyAsCan.length;261    }262263    if (accountsToCreate !== 0) throw Error(`Crowd generation failed: ${accountsToCreate} accounts left`);264265    return crowd;266  };267268  isDevNode = async () => {269    let blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON();270    if (blockNumber == 0) {271      await this.helper.wait.newBlocks(1); 272      blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON();273    }274    const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]);275    const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]);276    const findCreationDate = async (block: any) => {277      const humanBlock = block.toHuman();278      let date;279      humanBlock.block.extrinsics.forEach((ext: any) => {280        if(ext.method.section === 'timestamp') {281          date = Number(ext.method.args.now.replaceAll(',', ''));282        }283      });284      return date;285    };286    const block1date = await findCreationDate(block1);287    const block2date = await findCreationDate(block2);288    if(block2date! - block1date! < 9000) return true;289  };290  291  async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {292    const address = payer.Substrate ? payer.Substrate : await this.helper.address.ethToSubstrate(payer.Ethereum!);293    let balance = await this.helper.balance.getSubstrate(address); 294    295    await promise();296    297    balance -= await this.helper.balance.getSubstrate(address);298    299    return balance;300  }301302  calculatePalletAddress(palletId: any) {303    const address = stringToU8a(('modl' + palletId).padEnd(32, '\0'));304    return encodeAddress(address);305  }306307  async makeScheduledIds(num: number): Promise<string[]> {308    await this.helper.wait.noScheduledTasks();309310    function makeId(slider: number) {311      const scheduledIdSize = 64;312      const hexId = slider.toString(16);313      const prefixSize = scheduledIdSize - hexId.length;314315      const scheduledId = '0x' + '0'.repeat(prefixSize) + hexId;316317      return scheduledId;  318    }319320    const ids = [];321    for (let i = 0; i < num; i++) {322      ids.push(makeId(this.scheduledIdSlider));323      this.scheduledIdSlider += 1;324    }325326    return ids;327  }328329  async makeScheduledId(): Promise<string> {330    return (await this.makeScheduledIds(1))[0];331  }332333  async captureEvents(eventSection: string, eventMethod: string): Promise<EventCapture> {334    const capture = new EventCapture(this.helper, eventSection, eventMethod);335    await capture.startCapture();336337    return capture;338  }339}340341class MoonbeamAccountGroup {342  helper: MoonbeamHelper;343344  keyring: Keyring;345  _alithAccount: IKeyringPair;346  _baltatharAccount: IKeyringPair;347  _dorothyAccount: IKeyringPair;348349  constructor(helper: MoonbeamHelper) {350    this.helper = helper;351352    this.keyring = new Keyring({type: 'ethereum'});353    const alithPrivateKey = '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133';354    const baltatharPrivateKey = '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b';355    const dorothyPrivateKey = '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68';356357    this._alithAccount = this.keyring.addFromUri(alithPrivateKey, undefined, 'ethereum');358    this._baltatharAccount = this.keyring.addFromUri(baltatharPrivateKey, undefined, 'ethereum');359    this._dorothyAccount = this.keyring.addFromUri(dorothyPrivateKey, undefined, 'ethereum');360  }361362  alithAccount() {363    return this._alithAccount;364  }365366  baltatharAccount() {367    return this._baltatharAccount;368  }369370  dorothyAccount() {371    return this._dorothyAccount;372  }373374  create() {375    return this.keyring.addFromUri(mnemonicGenerate());376  }377}378379class WaitGroup {380  helper: ChainHelperBase;381382  constructor(helper: ChainHelperBase) {383    this.helper = helper;384  }385386  /**387   * Wait for specified number of blocks388   * @param blocksCount number of blocks to wait389   * @returns 390   */391  async newBlocks(blocksCount = 1): Promise<void> {392    // eslint-disable-next-line no-async-promise-executor393    const promise = new Promise<void>(async (resolve) => {394      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {395        if (blocksCount > 0) {396          blocksCount--;397        } else {398          unsubscribe();399          resolve();400        }401      });402    });403    return promise;404  }405406  async forParachainBlockNumber(blockNumber: bigint) {407    // eslint-disable-next-line no-async-promise-executor408    return new Promise<void>(async (resolve) => {409      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {410        if (data.number.toNumber() >= blockNumber) {411          unsubscribe();412          resolve();413        }414      });415    });416  }417  418  async forRelayBlockNumber(blockNumber: bigint) {419    // eslint-disable-next-line no-async-promise-executor420    return new Promise<void>(async (resolve) => {421      const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {422        if (data.value.relayParentNumber.toNumber() >= blockNumber) {423          // @ts-ignore424          unsubscribe();425          resolve();426        }427      });428    });429  }430431  async noScheduledTasks() {432    const api = this.helper.getApi();433    434    // eslint-disable-next-line no-async-promise-executor435    const promise = new Promise<void>(async resolve => {436      const unsubscribe = await api.rpc.chain.subscribeNewHeads(async () => {437        const areThereScheduledTasks = await api.query.scheduler.lookup.entries();438439        if(areThereScheduledTasks.length == 0) {440          unsubscribe();441          resolve();442        }443      }); 444    });445446    return promise;447  }448449  async event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {450    // eslint-disable-next-line no-async-promise-executor451    const promise = new Promise<EventRecord | null>(async (resolve) => {452      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {453        const blockNumber = header.number.toHuman();454        const blockHash = header.hash;455        const eventIdStr = `${eventSection}.${eventMethod}`;456        const waitLimitStr = `wait blocks remaining: ${maxBlocksToWait}`;457  458        this.helper.logger.log(`[Block #${blockNumber}] Waiting for event \`${eventIdStr}\` (${waitLimitStr})`);459  460        const apiAt = await this.helper.getApi().at(blockHash);461        const eventRecords = (await apiAt.query.system.events()) as any;462  463        const neededEvent = eventRecords.toArray().find((r: FrameSystemEventRecord) => {464          return r.event.section == eventSection && r.event.method == eventMethod;465        });466  467        if (neededEvent) {468          unsubscribe();469          resolve(neededEvent);470        } else if (maxBlocksToWait > 0) {471          maxBlocksToWait--;472        } else {473          this.helper.logger.log(`Event \`${eventIdStr}\` is NOT found`);474          unsubscribe();475          resolve(null);476        }477      });478    });479    return promise;480  }481}482483class TestUtilGroup {484  helper: DevUniqueHelper;485486  constructor(helper: DevUniqueHelper) {487    this.helper = helper;488  }489490  async enable() {491    if (this.helper.fetchMissingPalletNames([Pallets.TestUtils]).length != 0) {492      return;493    }494495    const signer = this.helper.util.fromSeed('//Alice');496    await this.helper.getSudo<DevUniqueHelper>().executeExtrinsic(signer, 'api.tx.testUtils.enable', [], true);497  }498499  async setTestValue(signer: TSigner, testVal: number) {500    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValue', [testVal], true);501  }502503  async incTestValue(signer: TSigner) {504    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.incTestValue', [], true);505  }506507  async setTestValueAndRollback(signer: TSigner, testVal: number) {508    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValueAndRollback', [testVal], true);509  }510511  async testValue() {512    return (await this.helper.callRpc('api.query.testUtils.testValue', [])).toNumber();513  }514515  async justTakeFee(signer: TSigner) {516    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.justTakeFee', [], true);517  }518519  async selfCancelingInc(signer: TSigner, scheduledId: string, maxTestVal: number) {520    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.selfCancelingInc', [scheduledId, maxTestVal], true);521  }522}523524class EventCapture {525  helper: DevUniqueHelper;526  eventSection: string;527  eventMethod: string;528  events: EventRecord[] = [];529  unsubscribe: VoidFn | null = null;530531  constructor(532    helper: DevUniqueHelper,533    eventSection: string,534    eventMethod: string,535  ) {536    this.helper = helper;537    this.eventSection = eventSection;538    this.eventMethod = eventMethod;539  }540541  async startCapture() {542    this.stopCapture();543    this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {544      const newEvents = eventRecords.filter(r => {545        return r.event.section == this.eventSection && r.event.method == this.eventMethod;546      });547548      this.events.push(...newEvents);549    })) as any;550  }551552  stopCapture() {553    if (this.unsubscribe !== null) {554      this.unsubscribe();555    }556  }557558  extractCapturedEvents() {559    return this.events;560  }561}562563class AdminGroup {564  helper: UniqueHelper;565566  constructor(helper: UniqueHelper) {567    this.helper = helper;568  }569570  async payoutStakers(signer: IKeyringPair, stakersToPayout: number) {571    const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);572    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {573      return {574        staker: e.event.data[0].toString(),575        stake: e.event.data[1].toBigInt(),576        payout: e.event.data[2].toBigInt(),577      };578    });579  }580}
after · tests/src/util/playgrounds/unique.dev.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {stringToU8a} from '@polkadot/util';5import {encodeAddress, mnemonicGenerate} from '@polkadot/util-crypto';6import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper, WestmintHelper} from './unique';7import {ApiPromise, Keyring, WsProvider} from '@polkadot/api';8import * as defs from '../../interfaces/definitions';9import {IKeyringPair} from '@polkadot/types/types';10import {EventRecord} from '@polkadot/types/interfaces';11import {ICrossAccountId, TSigner} from './types';12import {FrameSystemEventRecord} from '@polkadot/types/lookup';13import {VoidFn} from '@polkadot/api/types';14import {Pallets} from '..';1516export class SilentLogger {17  log(_msg: any, _level: any): void { }18  level = {19    ERROR: 'ERROR' as const,20    WARNING: 'WARNING' as const,21    INFO: 'INFO' as const,22  };23}2425export class SilentConsole {26  // TODO: Remove, this is temporary: Filter unneeded API output27  // (Jaco promised it will be removed in the next version)28  consoleErr: any;29  consoleLog: any;30  consoleWarn: any;3132  constructor() {33    this.consoleErr = console.error;34    this.consoleLog = console.log;35    this.consoleWarn = console.warn;36  }3738  enable() {  39    const outFn = (printer: any) => (...args: any[]) => {40      for (const arg of args) {41        if (typeof arg !== 'string')42          continue;43        if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')44          return;45      }46      printer(...args);47    };48  49    console.error = outFn(this.consoleErr.bind(console));50    console.log = outFn(this.consoleLog.bind(console));51    console.warn = outFn(this.consoleWarn.bind(console));52  }5354  disable() {55    console.error = this.consoleErr;56    console.log = this.consoleLog;57    console.warn = this.consoleWarn;58  }59}6061export class DevUniqueHelper extends UniqueHelper {62  /**63   * Arrange methods for tests64   */65  arrange: ArrangeGroup;66  wait: WaitGroup;67  admin: AdminGroup;68  testUtils: TestUtilGroup;6970  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {71    options.helperBase = options.helperBase ?? DevUniqueHelper;7273    super(logger, options);74    this.arrange = new ArrangeGroup(this);75    this.wait = new WaitGroup(this);76    this.admin = new AdminGroup(this);77    this.testUtils = new TestUtilGroup(this);78  }7980  async connect(wsEndpoint: string, _listeners?: any): Promise<void> {81    const wsProvider = new WsProvider(wsEndpoint);82    this.api = new ApiPromise({83      provider: wsProvider,84      signedExtensions: {85        ContractHelpers: {86          extrinsic: {},87          payload: {},88        },89        FakeTransactionFinalizer: {90          extrinsic: {},91          payload: {},92        },93      },94      rpc: {95        unique: defs.unique.rpc,96        appPromotion: defs.appPromotion.rpc,97        rmrk: defs.rmrk.rpc,98        eth: {99          feeHistory: {100            description: 'Dummy',101            params: [],102            type: 'u8',103          },104          maxPriorityFeePerGas: {105            description: 'Dummy',106            params: [],107            type: 'u8',108          },109        },110      },111    });112    await this.api.isReadyOrError;113    this.network = await UniqueHelper.detectNetwork(this.api);114  }115}116117export class DevRelayHelper extends RelayHelper {}118119export class DevWestmintHelper extends WestmintHelper {120  wait: WaitGroup;121122  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {123    options.helperBase = options.helperBase ?? DevWestmintHelper;124125    super(logger, options);126    this.wait = new WaitGroup(this);127  }128}129130export class DevMoonbeamHelper extends MoonbeamHelper {131  account: MoonbeamAccountGroup;132  wait: WaitGroup;133134  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {135    options.helperBase = options.helperBase ?? DevMoonbeamHelper;136137    super(logger, options);138    this.account = new MoonbeamAccountGroup(this);139    this.wait = new WaitGroup(this);140  }141}142143export class DevMoonriverHelper extends DevMoonbeamHelper {}144145export class DevAcalaHelper extends AcalaHelper {146  wait: WaitGroup;147148  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {149    options.helperBase = options.helperBase ?? DevAcalaHelper;150151    super(logger, options);152    this.wait = new WaitGroup(this);153  }154}155156export class DevKaruraHelper extends DevAcalaHelper {}157158class ArrangeGroup {159  helper: DevUniqueHelper;160161  scheduledIdSlider = 0;162163  constructor(helper: DevUniqueHelper) {164    this.helper = helper;165  }166167  /**168   * Generates accounts with the specified UNQ token balance 169   * @param balances balances for generated accounts. Each balance will be multiplied by the token nominal.170   * @param donor donor account for balances171   * @returns array of newly created accounts172   * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor); 173   */174  createAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {175    let nonce = await this.helper.chain.getNonce(donor.address);176    const wait = new WaitGroup(this.helper);177    const ss58Format = this.helper.chain.getChainProperties().ss58Format;178    const tokenNominal = this.helper.balance.getOneTokenNominal();179    const transactions = [];180    const accounts: IKeyringPair[] = [];181    for (const balance of balances) {182      const recipient = this.helper.util.fromSeed(mnemonicGenerate(), ss58Format);183      accounts.push(recipient);184      if (balance !== 0n) {185        const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recipient.address}, balance * tokenNominal]);186        transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));187        nonce++;188      }189    }190191    await Promise.all(transactions).catch(_e => {});192    193    //#region TODO remove this region, when nonce problem will be solved194    const checkBalances = async () => {195      let isSuccess = true;196      for (let i = 0; i < balances.length; i++) {197        const balance = await this.helper.balance.getSubstrate(accounts[i].address);198        if (balance !== balances[i] * tokenNominal) {199          isSuccess = false;200          break;201        }202      }203      return isSuccess;204    };205206    let accountsCreated = false;207    const maxBlocksChecked = await this.helper.arrange.isDevNode() ? 50 : 5;208    // checkBalances retry up to 5-50 blocks209    for (let index = 0; index < maxBlocksChecked; index++) {210      accountsCreated = await checkBalances();211      if(accountsCreated) break;212      await wait.newBlocks(1);213    }214215    if (!accountsCreated) throw Error('Accounts generation failed');216    //#endregion217218    return accounts;219  };220221  // TODO combine this method and createAccounts into one222  createCrowd = async (accountsToCreate: number, withBalance: bigint, donor: IKeyringPair): Promise<IKeyringPair[]> => {  223    const createAsManyAsCan = async () => {224      let transactions: any = [];225      const accounts: IKeyringPair[] = [];226      let nonce = await this.helper.chain.getNonce(donor.address);227      const tokenNominal = this.helper.balance.getOneTokenNominal();228      for (let i = 0; i < accountsToCreate; i++) {229        if (i === 500) { // if there are too many accounts to create230          await Promise.allSettled(transactions); // wait while first 500 (should be 100 for devnode) tx will be settled 231          transactions = []; //232          nonce = await this.helper.chain.getNonce(donor.address); // update nonce 233        }234        const recepient = this.helper.util.fromSeed(mnemonicGenerate());235        accounts.push(recepient);236        if (withBalance !== 0n) {237          const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recepient.address}, withBalance * tokenNominal]);238          transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));239          nonce++;240        }241      }242      243      const fullfilledAccounts = [];244      await Promise.allSettled(transactions);245      for (const account of accounts) {246        const accountBalance = await this.helper.balance.getSubstrate(account.address);247        if (accountBalance === withBalance * tokenNominal) {248          fullfilledAccounts.push(account);249        }250      }251      return fullfilledAccounts;252    };253254    255    const crowd: IKeyringPair[] = [];256    // do up to 5 retries257    for (let index = 0; index < 5 && accountsToCreate !== 0; index++) {258      const asManyAsCan = await createAsManyAsCan();259      crowd.push(...asManyAsCan);260      accountsToCreate -= asManyAsCan.length;261    }262263    if (accountsToCreate !== 0) throw Error(`Crowd generation failed: ${accountsToCreate} accounts left`);264265    return crowd;266  };267268  isDevNode = async () => {269    let blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON();270    if (blockNumber == 0) {271      await this.helper.wait.newBlocks(1); 272      blockNumber = (await this.helper.callRpc('api.query.system.number')).toJSON();273    }274    const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]);275    const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]);276    const findCreationDate = (block: any) => {277      const humanBlock = block.toHuman();278      let date;279      humanBlock.block.extrinsics.forEach((ext: any) => {280        if(ext.method.section === 'timestamp') {281          date = Number(ext.method.args.now.replaceAll(',', ''));282        }283      });284      return date;285    };286    const block1date = await findCreationDate(block1);287    const block2date = await findCreationDate(block2);288    if(block2date! - block1date! < 9000) return true;289  };290  291  async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {292    const address = payer.Substrate ? payer.Substrate : await this.helper.address.ethToSubstrate(payer.Ethereum!);293    let balance = await this.helper.balance.getSubstrate(address); 294    295    await promise();296    297    balance -= await this.helper.balance.getSubstrate(address);298    299    return balance;300  }301302  calculatePalletAddress(palletId: any) {303    const address = stringToU8a(('modl' + palletId).padEnd(32, '\0'));304    return encodeAddress(address);305  }306307  async makeScheduledIds(num: number): Promise<string[]> {308    await this.helper.wait.noScheduledTasks();309310    function makeId(slider: number) {311      const scheduledIdSize = 64;312      const hexId = slider.toString(16);313      const prefixSize = scheduledIdSize - hexId.length;314315      const scheduledId = '0x' + '0'.repeat(prefixSize) + hexId;316317      return scheduledId;  318    }319320    const ids = [];321    for (let i = 0; i < num; i++) {322      ids.push(makeId(this.scheduledIdSlider));323      this.scheduledIdSlider += 1;324    }325326    return ids;327  }328329  async makeScheduledId(): Promise<string> {330    return (await this.makeScheduledIds(1))[0];331  }332333  async captureEvents(eventSection: string, eventMethod: string): Promise<EventCapture> {334    const capture = new EventCapture(this.helper, eventSection, eventMethod);335    await capture.startCapture();336337    return capture;338  }339}340341class MoonbeamAccountGroup {342  helper: MoonbeamHelper;343344  keyring: Keyring;345  _alithAccount: IKeyringPair;346  _baltatharAccount: IKeyringPair;347  _dorothyAccount: IKeyringPair;348349  constructor(helper: MoonbeamHelper) {350    this.helper = helper;351352    this.keyring = new Keyring({type: 'ethereum'});353    const alithPrivateKey = '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133';354    const baltatharPrivateKey = '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b';355    const dorothyPrivateKey = '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68';356357    this._alithAccount = this.keyring.addFromUri(alithPrivateKey, undefined, 'ethereum');358    this._baltatharAccount = this.keyring.addFromUri(baltatharPrivateKey, undefined, 'ethereum');359    this._dorothyAccount = this.keyring.addFromUri(dorothyPrivateKey, undefined, 'ethereum');360  }361362  alithAccount() {363    return this._alithAccount;364  }365366  baltatharAccount() {367    return this._baltatharAccount;368  }369370  dorothyAccount() {371    return this._dorothyAccount;372  }373374  create() {375    return this.keyring.addFromUri(mnemonicGenerate());376  }377}378379class WaitGroup {380  helper: ChainHelperBase;381382  constructor(helper: ChainHelperBase) {383    this.helper = helper;384  }385386  /**387   * Wait for specified number of blocks388   * @param blocksCount number of blocks to wait389   * @returns 390   */391  newBlocks(blocksCount = 1): Promise<void> {392    // eslint-disable-next-line no-async-promise-executor393    const promise = new Promise<void>(async (resolve) => {394      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {395        if (blocksCount > 0) {396          blocksCount--;397        } else {398          unsubscribe();399          resolve();400        }401      });402    });403    return promise;404  }405406  forParachainBlockNumber(blockNumber: bigint) {407    // eslint-disable-next-line no-async-promise-executor408    return new Promise<void>(async (resolve) => {409      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {410        if (data.number.toNumber() >= blockNumber) {411          unsubscribe();412          resolve();413        }414      });415    });416  }417  418  forRelayBlockNumber(blockNumber: bigint) {419    // eslint-disable-next-line no-async-promise-executor420    return new Promise<void>(async (resolve) => {421      const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {422        if (data.value.relayParentNumber.toNumber() >= blockNumber) {423          // @ts-ignore424          unsubscribe();425          resolve();426        }427      });428    });429  }430431  noScheduledTasks() {432    const api = this.helper.getApi();433    434    // eslint-disable-next-line no-async-promise-executor435    const promise = new Promise<void>(async resolve => {436      const unsubscribe = await api.rpc.chain.subscribeNewHeads(async () => {437        const areThereScheduledTasks = await api.query.scheduler.lookup.entries();438439        if(areThereScheduledTasks.length == 0) {440          unsubscribe();441          resolve();442        }443      }); 444    });445446    return promise;447  }448449  event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {450    // eslint-disable-next-line no-async-promise-executor451    const promise = new Promise<EventRecord | null>(async (resolve) => {452      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {453        const blockNumber = header.number.toHuman();454        const blockHash = header.hash;455        const eventIdStr = `${eventSection}.${eventMethod}`;456        const waitLimitStr = `wait blocks remaining: ${maxBlocksToWait}`;457  458        this.helper.logger.log(`[Block #${blockNumber}] Waiting for event \`${eventIdStr}\` (${waitLimitStr})`);459  460        const apiAt = await this.helper.getApi().at(blockHash);461        const eventRecords = (await apiAt.query.system.events()) as any;462  463        const neededEvent = eventRecords.toArray().find((r: FrameSystemEventRecord) => {464          return r.event.section == eventSection && r.event.method == eventMethod;465        });466  467        if (neededEvent) {468          unsubscribe();469          resolve(neededEvent);470        } else if (maxBlocksToWait > 0) {471          maxBlocksToWait--;472        } else {473          this.helper.logger.log(`Event \`${eventIdStr}\` is NOT found`);474          unsubscribe();475          resolve(null);476        }477      });478    });479    return promise;480  }481}482483class TestUtilGroup {484  helper: DevUniqueHelper;485486  constructor(helper: DevUniqueHelper) {487    this.helper = helper;488  }489490  async enable() {491    if (this.helper.fetchMissingPalletNames([Pallets.TestUtils]).length != 0) {492      return;493    }494495    const signer = this.helper.util.fromSeed('//Alice');496    await this.helper.getSudo<DevUniqueHelper>().executeExtrinsic(signer, 'api.tx.testUtils.enable', [], true);497  }498499  async setTestValue(signer: TSigner, testVal: number) {500    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValue', [testVal], true);501  }502503  async incTestValue(signer: TSigner) {504    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.incTestValue', [], true);505  }506507  async setTestValueAndRollback(signer: TSigner, testVal: number) {508    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValueAndRollback', [testVal], true);509  }510511  async testValue() {512    return (await this.helper.callRpc('api.query.testUtils.testValue', [])).toNumber();513  }514515  async justTakeFee(signer: TSigner) {516    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.justTakeFee', [], true);517  }518519  async selfCancelingInc(signer: TSigner, scheduledId: string, maxTestVal: number) {520    await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.selfCancelingInc', [scheduledId, maxTestVal], true);521  }522}523524class EventCapture {525  helper: DevUniqueHelper;526  eventSection: string;527  eventMethod: string;528  events: EventRecord[] = [];529  unsubscribe: VoidFn | null = null;530531  constructor(532    helper: DevUniqueHelper,533    eventSection: string,534    eventMethod: string,535  ) {536    this.helper = helper;537    this.eventSection = eventSection;538    this.eventMethod = eventMethod;539  }540541  async startCapture() {542    this.stopCapture();543    this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {544      const newEvents = eventRecords.filter(r => {545        return r.event.section == this.eventSection && r.event.method == this.eventMethod;546      });547548      this.events.push(...newEvents);549    })) as any;550  }551552  stopCapture() {553    if (this.unsubscribe !== null) {554      this.unsubscribe();555    }556  }557558  extractCapturedEvents() {559    return this.events;560  }561}562563class AdminGroup {564  helper: UniqueHelper;565566  constructor(helper: UniqueHelper) {567    this.helper = helper;568  }569570  async payoutStakers(signer: IKeyringPair, stakersToPayout: number) {571    const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);572    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {573      return {574        staker: e.event.data[0].toString(),575        stake: e.event.data[1].toBigInt(),576        payout: e.event.data[2].toBigInt(),577      };578    });579  }580}
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1677,7 +1677,7 @@
    * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})
    * @returns ```true``` if extrinsic success, otherwise ```false```
    */
-  async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
+  approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
     return super.approveToken(signer, collectionId, tokenId, toAddressObj, 1n);
   }
 }
@@ -1870,7 +1870,7 @@
    * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5GHoZe9c73RYbVzq..."}, "", 10000n);
    * @returns true if the token success, otherwise false
    */
-  async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
+  approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
     return super.approveToken(signer, collectionId, tokenId, toAddressObj, amount);
   }
 
@@ -2082,7 +2082,7 @@
    * @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)
    * @returns ```true``` if extrinsic success, otherwise ```false```
    */
-  async approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {
+  approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {
     return super.approveToken(signer, collectionId, 0, toAddressObj, amount);
   }
 
@@ -2093,7 +2093,7 @@
    * @param toAddressObj the address approved for the transfer of tokens on behalf of the owner
    * @returns number of tokens approved for the transfer
    */
-  async getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {
+  getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {
     return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);
   }
 }
@@ -2270,7 +2270,7 @@
    * @example getSubstrate("5GrwvaEF5zXb26Fz...")
    * @returns amount of tokens on address
    */
-  async getSubstrate(address: TSubstrateAccount): Promise<bigint> {
+  getSubstrate(address: TSubstrateAccount): Promise<bigint> {
     return this.subBalanceGroup.getSubstrate(address);
   }
 
@@ -2279,7 +2279,7 @@
    * @param address substrate address
    * @returns
    */
-  async getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
+  getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
     return this.subBalanceGroup.getSubstrateFull(address);
   }
 
@@ -2289,7 +2289,7 @@
    * @example getEthereum("0x9F0583DbB855d...")
    * @returns amount of tokens on address
    */
-  async getEthereum(address: TEthereumAccount): Promise<bigint> {
+  getEthereum(address: TEthereumAccount): Promise<bigint> {
     return this.ethBalanceGroup.getEthereum(address);
   }
 
@@ -2301,7 +2301,7 @@
    * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);
    * @returns ```true``` if extrinsic success, otherwise ```false```
    */
-  async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
+  transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
     return this.subBalanceGroup.transferToSubstrate(signer, address, amount);
   }
 
@@ -2471,7 +2471,7 @@
     super(helper);
   }
 
-  async cancelScheduled(signer: TSigner, scheduledId: string) {
+  cancelScheduled(signer: TSigner, scheduledId: string) {
     return this.helper.executeExtrinsic(
       signer,
       'api.tx.scheduler.cancelNamed',
@@ -2480,7 +2480,7 @@
     );
   }
 
-  async changePriority(signer: TSigner, scheduledId: string, priority: number) {
+  changePriority(signer: TSigner, scheduledId: string, priority: number) {
     return this.helper.executeExtrinsic(
       signer,
       'api.tx.scheduler.changeNamedPriority',