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

difftreelog

Merge pull request #377 from UniqueNetwork/feature/CORE-302-ss58Format

kozyrevdev2022-06-09parents: #0f16e44 #bd269a2.patch.diff
in: master
test(ss58Format): more test fixes

3 files changed

modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -17,7 +17,6 @@
 import {ApiPromise} from '@polkadot/api';
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
 import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
 import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';
 
@@ -45,11 +44,11 @@
 
 describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
   it("Not owner can't add collection admin.", async () => {
-    await usingApi(async (api) => {
+    await usingApi(async (api, privateKeyWrapper) => {
       const collectionId = await createCollectionExpectSuccess();
-      const alice = privateKey('//Alice');
-      const bob = privateKey('//Bob');
-      const charlie = privateKey('//CHARLIE');
+      const alice = privateKeyWrapper('//Alice');
+      const bob = privateKeyWrapper('//Bob');
+      const charlie = privateKeyWrapper('//CHARLIE');
 
       const collection = await queryCollectionExpectSuccess(api, collectionId);
       expect(collection.owner.toString()).to.be.equal(alice.address);
@@ -67,11 +66,11 @@
   });
 
   it("Admin can't add collection admin.", async () => {
-    await usingApi(async (api) => {
+    await usingApi(async (api, privateKeyWrapper) => {
       const collectionId = await createCollectionExpectSuccess();
-      const alice = privateKey('//Alice');
-      const bob = privateKey('//Bob');
-      const charlie = privateKey('//CHARLIE');
+      const alice = privateKeyWrapper('//Alice');
+      const bob = privateKeyWrapper('//Bob');
+      const charlie = privateKeyWrapper('//CHARLIE');
 
       const collection = await queryCollectionExpectSuccess(api, collectionId);
       expect(collection.owner.toString()).to.be.equal(alice.address);
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 privateKey from './substrate/privateKey';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';21import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';2223chai.use(chaiAsPromised);24const expect = chai.expect;2526describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {27  it('Remove collection admin.', async () => {28    await usingApi(async (api, privateKeyWrapper) => {29      const collectionId = await createCollectionExpectSuccess();30      const alice = privateKeyWrapper('//Alice');31      const bob = privateKeyWrapper('//Bob');32      const collection = await queryCollectionExpectSuccess(api, collectionId);33      expect(collection.owner.toString()).to.be.deep.eq(alice.address);34      // first - add collection admin Bob35      const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));36      await submitTransactionAsync(alice, addAdminTx);3738      const adminListAfterAddAdmin = await getAdminList(api, collectionId);39      expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));4041      // then remove bob from admins of collection42      const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));43      await submitTransactionAsync(alice, removeAdminTx);4445      const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);46      expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));47    });48  });4950  it('Remove admin from collection that has no admins', async () => {51    await usingApi(async (api, privateKeyWrapper) => {52      const alice = privateKeyWrapper('//Alice');53      const collectionId = await createCollectionExpectSuccess();5455      const adminListBeforeAddAdmin = await getAdminList(api, collectionId);56      expect(adminListBeforeAddAdmin).to.have.lengthOf(0);5758      const tx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));59      await submitTransactionAsync(alice, tx);60    });61  });62});6364describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {65  it('Can\'t remove collection admin from not existing collection', async () => {66    await usingApi(async (api, privateKeyWrapper) => {67      // tslint:disable-next-line: no-bitwise68      const collectionId = (1 << 32) - 1;69      const alice = privateKeyWrapper('//Alice');70      const bob = privateKeyWrapper('//Bob');7172      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));73      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;7475      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)76      await createCollectionExpectSuccess();77    });78  });7980  it('Can\'t remove collection admin from deleted collection', async () => {81    await usingApi(async (api, privateKeyWrapper) => {82      // tslint:disable-next-line: no-bitwise83      const collectionId = await createCollectionExpectSuccess();84      const alice = privateKeyWrapper('//Alice');85      const bob = privateKeyWrapper('//Bob');8687      await destroyCollectionExpectSuccess(collectionId);8889      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));90      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;9192      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)93      await createCollectionExpectSuccess();94    });95  });9697  it('Regular user can\'t remove collection admin', async () => {98    await usingApi(async (api) => {99      const collectionId = await createCollectionExpectSuccess();100      const alice = privateKey('//Alice');101      const bob = privateKey('//Bob');102      const charlie = privateKey('//Charlie');103104      const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));105      await submitTransactionAsync(alice, addAdminTx);106107      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));108      await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;109110      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)111      await createCollectionExpectSuccess();112    });113  });114115  it('Admin can\'t remove collection admin.', async () => {116    await usingApi(async (api) => {117      const collectionId = await createCollectionExpectSuccess();118      const alice = privateKey('//Alice');119      const bob = privateKey('//Bob');120      const charlie = privateKey('//Charlie');121122      const adminListAfterAddAdmin = await getAdminList(api, collectionId);123      expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));124125      const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));126      await expect(submitTransactionAsync(charlie, removeAdminTx)).to.be.rejected;127128      const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);129      expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(bob.address));130      expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(charlie.address));131    });132  });133});
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 {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';2122chai.use(chaiAsPromised);23const expect = chai.expect;2425describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {26  it('Remove collection admin.', async () => {27    await usingApi(async (api, privateKeyWrapper) => {28      const collectionId = await createCollectionExpectSuccess();29      const alice = privateKeyWrapper('//Alice');30      const bob = privateKeyWrapper('//Bob');31      const collection = await queryCollectionExpectSuccess(api, collectionId);32      expect(collection.owner.toString()).to.be.deep.eq(alice.address);33      // first - add collection admin Bob34      const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));35      await submitTransactionAsync(alice, addAdminTx);3637      const adminListAfterAddAdmin = await getAdminList(api, collectionId);38      expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));3940      // then remove bob from admins of collection41      const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));42      await submitTransactionAsync(alice, removeAdminTx);4344      const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);45      expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));46    });47  });4849  it('Remove admin from collection that has no admins', async () => {50    await usingApi(async (api, privateKeyWrapper) => {51      const alice = privateKeyWrapper('//Alice');52      const collectionId = await createCollectionExpectSuccess();5354      const adminListBeforeAddAdmin = await getAdminList(api, collectionId);55      expect(adminListBeforeAddAdmin).to.have.lengthOf(0);5657      const tx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));58      await submitTransactionAsync(alice, tx);59    });60  });61});6263describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {64  it('Can\'t remove collection admin from not existing collection', async () => {65    await usingApi(async (api, privateKeyWrapper) => {66      // tslint:disable-next-line: no-bitwise67      const collectionId = (1 << 32) - 1;68      const alice = privateKeyWrapper('//Alice');69      const bob = privateKeyWrapper('//Bob');7071      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));72      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;7374      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)75      await createCollectionExpectSuccess();76    });77  });7879  it('Can\'t remove collection admin from deleted collection', async () => {80    await usingApi(async (api, privateKeyWrapper) => {81      // tslint:disable-next-line: no-bitwise82      const collectionId = await createCollectionExpectSuccess();83      const alice = privateKeyWrapper('//Alice');84      const bob = privateKeyWrapper('//Bob');8586      await destroyCollectionExpectSuccess(collectionId);8788      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));89      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;9091      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)92      await createCollectionExpectSuccess();93    });94  });9596  it('Regular user can\'t remove collection admin', async () => {97    await usingApi(async (api, privateKeyWrapper) => {98      const collectionId = await createCollectionExpectSuccess();99      const alice = privateKeyWrapper('//Alice');100      const bob = privateKeyWrapper('//Bob');101      const charlie = privateKeyWrapper('//Charlie');102103      const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));104      await submitTransactionAsync(alice, addAdminTx);105106      const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));107      await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;108109      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)110      await createCollectionExpectSuccess();111    });112  });113114  it('Admin can\'t remove collection admin.', async () => {115    await usingApi(async (api, privateKeyWrapper) => {116      const collectionId = await createCollectionExpectSuccess();117      const alice = privateKeyWrapper('//Alice');118      const bob = privateKeyWrapper('//Bob');119      const charlie = privateKeyWrapper('//Charlie');120121      const adminListAfterAddAdmin = await getAdminList(api, collectionId);122      expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));123124      const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));125      await expect(submitTransactionAsync(charlie, removeAdminTx)).to.be.rejected;126127      const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);128      expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(bob.address));129      expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(charlie.address));130    });131  });132});
modifiedtests/src/scheduler.test.tsdiffbeforeafterboth
--- a/tests/src/scheduler.test.ts
+++ b/tests/src/scheduler.test.ts
@@ -16,7 +16,6 @@
 
 import chai, {expect} from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
 import {
   default as usingApi, 
   submitTransactionAsync,