git.delta.rocks / unique-network / refs/commits / 67ac05174e08

difftreelog

test fix eslint warnings

Yaroslav Bolyukin2022-05-30parent: #4eba81a.patch.diff
in: master

4 files changed

modifiedtests/src/createItem.test.tsdiffbeforeafterboth
--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {default as usingApi, executeTransaction} from './substrate/substrate-api';
+import {default as usingApi} from './substrate/substrate-api';
 import chai from 'chai';
 import {Keyring} from '@polkadot/api';
 import {IKeyringPair} from '@polkadot/types/types';
@@ -125,7 +125,7 @@
   });
 
   it('No editing rights', async () => {
-    await usingApi(async api => {
+    await usingApi(async () => {
       const createMode = 'NFT';
       const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 
         propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
@@ -136,14 +136,14 @@
   });
 
   it('User doesnt have editing rights', async () => {
-    await usingApi(async api => {
+    await usingApi(async () => {
       const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
       await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);
     });
   });
 
   it('Adding property without access rights', async () => {
-    await usingApi(async api => {
+    await usingApi(async () => {
       const newCollectionID = await createCollectionWithPropsExpectSuccess();
       await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
 
@@ -152,7 +152,7 @@
   });
 
   it('Adding more than 64 prps', async () => {
-    await usingApi(async api => {
+    await usingApi(async () => {
       const prps = [];
 
       for (let i = 0; i < 65; i++) {
@@ -166,7 +166,7 @@
   });
 
   it('Trying to add bigger property than allowed', async () => {
-    await usingApi(async api => {
+    await usingApi(async () => {
       const newCollectionID = await createCollectionWithPropsExpectSuccess();
       
       createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', 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
@@ -49,13 +49,13 @@
       const alice = privateKey('//Alice');
       await submitTransactionAsync(
         alice, 
-        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}])
+        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),
       );
       
       const args = [
         {NFT: {properties: [{key: 'data', value: '1'}]}},
         {NFT: {properties: [{key: 'data', value: '2'}]}},
-        {NFT: {properties: [{key: 'data', value: '3'}]}}
+        {NFT: {properties: [{key: 'data', value: '3'}]}},
       ];
       const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       await submitTransactionAsync(alice, createMultipleItemsTx);
@@ -143,7 +143,7 @@
       const args = [
         {NFT: {properties: [{key: 'k', value: 'v1'}]}},
         {NFT: {properties: [{key: 'k', value: 'v2'}]}},
-        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}},
       ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -171,7 +171,7 @@
       const args = [
         {NFT: {properties: [{key: 'k', value: 'v1'}]}},
         {NFT: {properties: [{key: 'k', value: 'v2'}]}},
-        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}},
       ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -190,16 +190,14 @@
 
   it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess(
-        {propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
-      );
+      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       const alice = privateKey('//Alice');
       const args = [
         {NFT: {properties: [{key: 'k', value: 'v1'}]}},
         {NFT: {properties: [{key: 'k', value: 'v2'}]}},
-        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}},
       ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
@@ -230,16 +228,14 @@
 
   it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess(
-        {propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
-      );
+      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
       const args = [
         {NFT: {properties: [{key: 'data', value: 'v1'}]}},
         {NFT: {properties: [{key: 'data', value: 'v2'}]}},
-        {NFT: {properties: [{key: 'data', value: 'v3'}]}}
+        {NFT: {properties: [{key: 'data', value: 'v3'}]}},
       ];
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
@@ -358,9 +354,7 @@
   it('Create token in not existing collection', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await getCreatedCollectionCount(api) + 1;
-      const createMultipleItemsTx = api.tx.unique.createMultipleItems(
-        collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']
-      );
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);
       await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);
     });
   });
@@ -369,7 +363,7 @@
     await usingApi(async (api: ApiPromise) => {
       // NFT
       const collectionId = await createCollectionWithPropsExpectSuccess({
-        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
       });
       const alice = privateKey('//Alice');
       const args = [
@@ -399,11 +393,7 @@
       const collectionId = await createCollectionExpectSuccess();
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);
-      await expect(
-        executeTransaction(api, alice, createMultipleItemsTx)
-      ).to.be.rejectedWith(
-        /nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/
-      );
+      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);
       // garbage collection :-D // lol
       await destroyCollectionExpectSuccess(collectionId);
     });
@@ -412,7 +402,7 @@
   it('Create tokens with different data limits <> maximum data limit', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionWithPropsExpectSuccess({
-        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
       });
       const args = [
         {NFT: {properties: [{key: 'key', value: 'A'}]}},
@@ -441,7 +431,7 @@
   it('User doesnt have editing rights', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionWithPropsExpectSuccess({
-        propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]
+        propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
       });
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
@@ -449,7 +439,7 @@
       const args = [
         {NFT: {properties: [{key: 'key1', value: 'v2'}]}},
         {NFT: {}},
-        {NFT: {}}
+        {NFT: {}},
       ];
 
       const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
@@ -497,11 +487,11 @@
       const args = [
         {NFT: {properties: prps}},
         {NFT: {properties: prps}},
-        {NFT: {properties: prps}}
+        {NFT: {properties: prps}},
       ];
 
       // there are no permissions, but will fail anyway because of too much weight for a block
-      const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);;
+      const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;
     });
   });
@@ -509,7 +499,7 @@
   it('Trying to add bigger property than allowed', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionWithPropsExpectSuccess({
-        propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+        propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
       });
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -16,8 +16,8 @@
 
 import {expect} from 'chai';
 import privateKey from './substrate/privateKey';
-import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';
+import usingApi, {executeTransaction} from './substrate/substrate-api';
+import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess} from './util/helpers';
 
 describe('createMultipleItemsEx', () => {
   it('can initialize multiple NFT with different owners', async () => {
@@ -175,7 +175,6 @@
       propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
-    const charlie = privateKey('//Charlie');
     await addCollectionAdminExpectSuccess(alice, collection, bob.address);
     await usingApi(async (api) => {
       const data = [
@@ -236,9 +235,7 @@
     const alice = privateKey('//Alice');
     const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
     await usingApi(async (api) => {
-      await expect(
-        executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))
-      ).to.be.rejectedWith(/common\.PropertyLimitReached/);
+      await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
     });
   });
 
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
561561
562 expect(result.success).to.be.true;562 expect(result.success).to.be.true;
563 });563 });
564}564};
565565
566export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {566export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
567 await usingApi(async (api) => {567 await usingApi(async (api) => {