difftreelog
Merge branch 'develop' into feature/NFTPAR-236_burn_item
in: master
3 files changed
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -20,6 +20,7 @@
"load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",
"testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",
"testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",
+ "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",
"testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
"testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts"
},
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -0,0 +1,82 @@
+import { ApiPromise } from '@polkadot/api';
+import BN from 'bn.js';
+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 {createCollectionExpectSuccess, destroyCollectionExpectSuccess} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
+ it('Remove collection admin.', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const collectionId = await createCollectionExpectSuccess();
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const collection: any = (await api.query.nft.collection(collectionId));
+ expect(collection.Owner.toString()).to.be.eq(Alice.address);
+ // first - add collection admin Bob
+ const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+ await submitTransactionAsync(Alice, addAdminTx);
+
+ const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
+ expect(adminListAfterAddAdmin).to.be.contains(Bob.address);
+
+ // then remove bob from admins of collection
+ const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+ await submitTransactionAsync(Alice, removeAdminTx);
+
+ const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId));
+ expect(adminListAfterRemoveAdmin).not.to.be.contains(Bob.address);
+ });
+ });
+});
+
+describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
+ it('Can\'t remove collection admin from not existing collection', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ // tslint:disable-next-line: no-bitwise
+ const collectionId = (1 << 32) - 1;
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
+ const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, bob.address);
+ await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
+
+ // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
+ await createCollectionExpectSuccess();
+ });
+ });
+
+ it('Can\'t remove collection admin from deleted collection', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ // tslint:disable-next-line: no-bitwise
+ const collectionId = await createCollectionExpectSuccess();
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+
+ await destroyCollectionExpectSuccess(collectionId);
+
+ const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+ await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
+
+ // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
+ await createCollectionExpectSuccess();
+ });
+ });
+
+ it('Remove admin from collection that has no admins', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const collectionId = await createCollectionExpectSuccess();
+
+ const adminListBeforeAddAdmin: any = (await api.query.nft.adminList(collectionId));
+ expect(adminListBeforeAddAdmin).to.have.lengthOf(0);
+
+ const tx = api.tx.nft.removeCollectionAdmin(collectionId, Alice.address);
+ await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ });
+ });
+});
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth93 const nonExistedCollectionId = collectionCount + 1;93 const nonExistedCollectionId = collectionCount + 1;94 tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');94 tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');95 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;95 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;96 /*try {97 await submitTransactionAsync(alice, tx);98 } catch (e) {99 // tslint:disable-next-line:no-unused-expression100 expect(e).to.be.exist;101 }*/102 });96 });103 });97 });10498119 await destroyCollectionExpectSuccess(collectionIdForTesting);113 await destroyCollectionExpectSuccess(collectionIdForTesting);120 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');114 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');121 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;115 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;122 /*try {123 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');124 await submitTransactionAsync(alice, tx);125 } catch (e) {126 // tslint:disable-next-line:no-unused-expression127 expect(e).to.be.exist;128 }*/129 });116 });130 });117 });131});118});