git.delta.rocks / unique-network / refs/commits / 02103120d101

difftreelog

fix eslint errors and warnings in tests

Maksandre2022-08-09parent: #c2a1147.patch.diff
in: master

3 files changed

modifiedtests/src/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -15,9 +15,9 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import { U128_MAX } from './util/helpers';
+import {U128_MAX} from './util/helpers';
 
-import { usingPlaygrounds } from './util/playgrounds';
+import {usingPlaygrounds} from './util/playgrounds';
 
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
@@ -37,16 +37,16 @@
 
   it('Create fungible collection and token', async () => {
     await usingPlaygrounds(async helper => {
-        const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'trest'});
-        const defaultTokenId = await collection.getLastTokenId();
-        expect(defaultTokenId).to.be.equal(0);
+      const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'trest'});
+      const defaultTokenId = await collection.getLastTokenId();
+      expect(defaultTokenId).to.be.equal(0);
 
-        await collection.mint(alice, {Substrate: alice.address}, U128_MAX);
-        const aliceBalance = await collection.getBalance({Substrate: alice.address});
-        const itemCountAfter = await collection.getLastTokenId();
+      await collection.mint(alice, {Substrate: alice.address}, U128_MAX);
+      const aliceBalance = await collection.getBalance({Substrate: alice.address});
+      const itemCountAfter = await collection.getLastTokenId();
 
-        expect(itemCountAfter).to.be.equal(defaultTokenId);
-        expect(aliceBalance).to.be.equal(U128_MAX);
+      expect(itemCountAfter).to.be.equal(defaultTokenId);
+      expect(aliceBalance).to.be.equal(U128_MAX);
     });
   });
   
@@ -103,7 +103,7 @@
       await collection.mintWithOneOwner(alice, {Substrate: alice.address}, [
         {value: 500n},
         {value: 400n},
-        {value: 300n}
+        {value: 300n},
       ]);
 
       expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1200n);
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -16,7 +16,7 @@
 
 import {IKeyringPair} from '@polkadot/types/types';
 
-import { usingPlaygrounds } from './util/playgrounds';
+import {usingPlaygrounds} from './util/playgrounds';
 
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
@@ -105,7 +105,7 @@
       await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, [
         {pieces: 1n}, 
         {pieces: 2n}, 
-        {pieces: 100n}
+        {pieces: 100n},
       ]);
       const lastTokenId = await collection.getLastTokenId();
       expect(lastTokenId).to.be.equal(3);
@@ -223,9 +223,9 @@
           collection.collectionId.toString(), 
           token.tokenId.toString(), 
           {Substrate: alice.address}, 
-          '100'
-        ]
-      }])
+          '100',
+        ],
+      }]);
     });
   });
 
@@ -243,9 +243,9 @@
           collection.collectionId.toString(), 
           token.tokenId.toString(), 
           {Substrate: alice.address}, 
-          '50'
-        ]
-      }])
+          '50',
+        ],
+      }]);
     });
   });
 });
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
before · tests/src/removeCollectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import { usingPlaygrounds } from './util/playgrounds';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {25  it('Remove collection admin.', async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      const alice = privateKey('//Alice');28      const bob = privateKey('//Bob');29      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});30      const collectionInfo = await collection.getData();31      expect(collectionInfo?.raw.owner.toString()).to.be.deep.eq(alice.address);32      // first - add collection admin Bob33      await collection.addAdmin(alice, {Substrate: bob.address});3435      const adminListAfterAddAdmin = await collection.getAdmins();36      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});3738      // then remove bob from admins of collection39      await collection.removeAdmin(alice, {Substrate: bob.address});4041      const adminListAfterRemoveAdmin = await collection.getAdmins();42      expect(adminListAfterRemoveAdmin).not.to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});43    });44  });4546  it('Remove admin from collection that has no admins', async () => {47    await usingPlaygrounds(async (helper, privateKey) => {48      const alice = privateKey('//Alice');49      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});5051      const adminListBeforeAddAdmin = await collection.getAdmins();52      expect(adminListBeforeAddAdmin).to.have.lengthOf(0);5354      // await expect(collection.removeAdmin(alice, {Substrate: alice.address})).to.be.rejectedWith('Unable to remove collection admin');55      await collection.removeAdmin(alice, {Substrate: alice.address});56    });57  });58});5960describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {61  it('Can\'t remove collection admin from not existing collection', async () => {62    await usingPlaygrounds(async (helper, privateKey) => {63      // tslint:disable-next-line: no-bitwise64      const collectionId = (1 << 32) - 1;65      const alice = privateKey('//Alice');66      const bob = privateKey('//Bob');6768      await expect(helper.collection.removeAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejected;6970      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)71      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});72    });73  });7475  it('Can\'t remove collection admin from deleted collection', async () => {76    await usingPlaygrounds(async (helper, privateKey) => {77      const alice = privateKey('//Alice');78      const bob = privateKey('//Bob');79      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});8081      expect(await collection.burn(alice)).to.be.true;8283      await expect(helper.collection.removeAdmin(alice, collection.collectionId, {Substrate: bob.address})).to.be.rejected;8485      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)86      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});87    });88  });8990  it('Regular user can\'t remove collection admin', async () => {91    await usingPlaygrounds(async (helper, privateKey) => {92      const alice = privateKey('//Alice');93      const bob = privateKey('//Bob');94      const charlie = privateKey('//Charlie');95      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});9697      await collection.addAdmin(alice, {Substrate: bob.address});9899      await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;100101      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)102      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});103    });104  });105106  it('Admin can\'t remove collection admin.', async () => {107    await usingPlaygrounds(async (helper, privateKey) => {108      const alice = privateKey('//Alice');109      const bob = privateKey('//Bob');110      const charlie = privateKey('//Charlie');111      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});112      113      await collection.addAdmin(alice, {Substrate: bob.address});114      await collection.addAdmin(alice, {Substrate: charlie.address});115116      const adminListAfterAddAdmin = await collection.getAdmins();117      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});118      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});119120      await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;121122      const adminListAfterRemoveAdmin = await collection.getAdmins();123      expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});124      expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});125    });126  });127});
after · tests/src/removeCollectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import {usingPlaygrounds} from './util/playgrounds';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {25  it('Remove collection admin.', async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      const alice = privateKey('//Alice');28      const bob = privateKey('//Bob');29      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});30      const collectionInfo = await collection.getData();31      expect(collectionInfo?.raw.owner.toString()).to.be.deep.eq(alice.address);32      // first - add collection admin Bob33      await collection.addAdmin(alice, {Substrate: bob.address});3435      const adminListAfterAddAdmin = await collection.getAdmins();36      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});3738      // then remove bob from admins of collection39      await collection.removeAdmin(alice, {Substrate: bob.address});4041      const adminListAfterRemoveAdmin = await collection.getAdmins();42      expect(adminListAfterRemoveAdmin).not.to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});43    });44  });4546  it('Remove admin from collection that has no admins', async () => {47    await usingPlaygrounds(async (helper, privateKey) => {48      const alice = privateKey('//Alice');49      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});5051      const adminListBeforeAddAdmin = await collection.getAdmins();52      expect(adminListBeforeAddAdmin).to.have.lengthOf(0);5354      // await expect(collection.removeAdmin(alice, {Substrate: alice.address})).to.be.rejectedWith('Unable to remove collection admin');55      await collection.removeAdmin(alice, {Substrate: alice.address});56    });57  });58});5960describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {61  it('Can\'t remove collection admin from not existing collection', async () => {62    await usingPlaygrounds(async (helper, privateKey) => {63      // tslint:disable-next-line: no-bitwise64      const collectionId = (1 << 32) - 1;65      const alice = privateKey('//Alice');66      const bob = privateKey('//Bob');6768      await expect(helper.collection.removeAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejected;6970      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)71      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});72    });73  });7475  it('Can\'t remove collection admin from deleted collection', async () => {76    await usingPlaygrounds(async (helper, privateKey) => {77      const alice = privateKey('//Alice');78      const bob = privateKey('//Bob');79      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});8081      expect(await collection.burn(alice)).to.be.true;8283      await expect(helper.collection.removeAdmin(alice, collection.collectionId, {Substrate: bob.address})).to.be.rejected;8485      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)86      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});87    });88  });8990  it('Regular user can\'t remove collection admin', async () => {91    await usingPlaygrounds(async (helper, privateKey) => {92      const alice = privateKey('//Alice');93      const bob = privateKey('//Bob');94      const charlie = privateKey('//Charlie');95      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});9697      await collection.addAdmin(alice, {Substrate: bob.address});9899      await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;100101      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)102      await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});103    });104  });105106  it('Admin can\'t remove collection admin.', async () => {107    await usingPlaygrounds(async (helper, privateKey) => {108      const alice = privateKey('//Alice');109      const bob = privateKey('//Bob');110      const charlie = privateKey('//Charlie');111      const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});112      113      await collection.addAdmin(alice, {Substrate: bob.address});114      await collection.addAdmin(alice, {Substrate: charlie.address});115116      const adminListAfterAddAdmin = await collection.getAdmins();117      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});118      expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});119120      await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;121122      const adminListAfterRemoveAdmin = await collection.getAdmins();123      expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});124      expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});125    });126  });127});