difftreelog
tests fixes
in: master
1 file changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth4import chaiAsPromised from 'chai-as-promised';
4import chaiAsPromised from 'chai-as-promised';
5import privateKey from './substrate/privateKey';
5import privateKey from './substrate/privateKey';
6import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
6import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
7import { createCollectionExpectSuccess } from './util/helpers';
7import {createCollectionExpectSuccess, destroyCollectionExpectSuccess} from './util/helpers';
8
8
9chai.use(chaiAsPromised);
9chai.use(chaiAsPromised);
10const expect = chai.expect;
10const expect = chai.expect;
27 });
27 });
28 });
28 });
29
30 it('Add admin using added collection admin.', async () => {
31 await usingApi(async (api) => {
32 const collectionId = await createCollectionExpectSuccess();
33 const Alice = privateKey('//Alice');
34 const Bob = privateKey('//Bob');
35 const Charlie = privateKey('//CHARLIE');
36
37 const collection: any = (await api.query.nft.collection(collectionId));
38 expect(collection.Owner.toString()).to.be.eq(Alice.address);
39
40 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
41 await submitTransactionAsync(Alice, changeAdminTx);
42
43 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
44 expect(adminListAfterAddAdmin).to.be.contains(Bob.address);
45
46 const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, Charlie.address);
47 await submitTransactionAsync(Bob, changeAdminTxCharlie);
48 const adminListAfterAddNewAdmin: any = (await api.query.nft.adminList(collectionId));
49 expect(adminListAfterAddNewAdmin).to.be.contains(Charlie.address);
50 });
51 });
29});
52});
30
53
31describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
54describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
60 });
83 });
61 });
84 });
62
85
86 it("Can't add collection admin of destroyed collection.", async () => {
87 await usingApi(async (api) => {
88 const collectionId = await createCollectionExpectSuccess();
89 const Alice = privateKey('//Alice');
90 const Bob = privateKey('//Bob');
91 await destroyCollectionExpectSuccess(collectionId);
92 const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
93 await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
94
95 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
96 await createCollectionExpectSuccess();
97 });
98 });
99
63 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
100 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
64 await usingApi(async (api: ApiPromise) => {
101 await usingApi(async (api: ApiPromise) => {
82 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
119 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
83 await submitTransactionAsync(Alice, changeAdminTx);
120 await submitTransactionAsync(Alice, changeAdminTx);
84 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
121 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
85 adminListAfterAddAdmin.map((item: any) => console.log(item.toString()));
86 expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
122 expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
87 }
123 }
88
124