difftreelog
tests fix
in: master
2 files changed
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -17,7 +17,8 @@
},
"scripts": {
"test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",
- "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts"
+ "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",
+ "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts"
},
"author": "",
"license": "Apache 2.0",
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth1import chai from 'chai';
2import chaiAsPromised from 'chai-as-promised';
3import privateKey from './substrate/privateKey';
4import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
5import { createCollectionExpectSuccess } from './util/helpers';
6
7chai.use(chaiAsPromised);
8const expect = chai.expect;
9
10describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
11 it('Add collection admin.', async () => {
12 await usingApi(async (api) => {
13 const collectionId = await createCollectionExpectSuccess();
14 const alice = privateKey('//Alice');
15 const bob = privateKey('//Bob');
16
17 const collection: any = (await api.query.nft.collection(collectionId));
18 expect(collection.Owner.toString()).to.be.eq(alice.address);
19
20 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);
21 await submitTransactionAsync(alice, changeAdminTx);
22
23 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
24 expect(adminListAfterAddAdmin).to.be.contains(bob.address);
25 });
26 });
27});
28
29describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
30 it("Not owner can't add collection admin.", async () => {
31 await usingApi(async (api) => {
32 const collectionId = await createCollectionExpectSuccess();
33 const alice = privateKey('//Alice');
34 const nonOwner = privateKey('//Bob_stash');
35
36 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, alice.address);
37 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;
38
39 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
40 expect(adminListAfterAddAdmin).not.to.be.contains(alice.address);
41
42 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
43 await createCollectionExpectSuccess();
44 });
45 });
46 it("Can't add collection admin of not existing collection.", async () => {
47 await usingApi(async (api) => {
48 // tslint:disable-next-line: no-bitwise
49 const collectionId = (1 << 32) - 1;
50 const alice = privateKey('//Alice');
51 const bob = privateKey('//Bob');
52
53 const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, bob.address);
54 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
55
56 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
57 await createCollectionExpectSuccess();
58 });
59 });
60});