difftreelog
CORE-402 Fix test for remove admin
in: master
1 file changed
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth161617import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import privateKey from './substrate/privateKey';19import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';21import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';212246 });47 });47 });48 });4849 it('Remove collection admin by admin.', async () => {50 await usingApi(async (api, privateKeyWrapper) => {51 const collectionId = await createCollectionExpectSuccess();52 const alice = privateKeyWrapper('//Alice');53 const bob = privateKeyWrapper('//Bob');54 const charlie = privateKeyWrapper('//Charlie');55 const collection = await queryCollectionExpectSuccess(api, collectionId);56 expect(collection.owner.toString()).to.be.eq(alice.address);57 // first - add collection admin Bob58 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));59 await submitTransactionAsync(alice, addAdminTx);6061 const addAdminTx2 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));62 await submitTransactionAsync(alice, addAdminTx2);6364 const adminListAfterAddAdmin = await getAdminList(api, collectionId);65 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));6667 // then remove bob from admins of collection68 const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));69 await submitTransactionAsync(charlie, removeAdminTx);7071 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);72 expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));73 });74 });754976 it('Remove admin from collection that has no admins', async () => {50 it('Remove admin from collection that has no admins', async () => {77 await usingApi(async (api, privateKeyWrapper) => {51 await usingApi(async (api, privateKeyWrapper) => {120 });94 });121 });95 });12296123 it('Regular user Can\'t remove collection admin', async () => {97 it('Regular user can\'t remove collection admin', async () => {124 await usingApi(async (api, privateKeyWrapper) => {98 await usingApi(async (api) => {125 const collectionId = await createCollectionExpectSuccess();99 const collectionId = await createCollectionExpectSuccess();126 const alice = privateKeyWrapper('//Alice');100 const alice = privateKey('//Alice');127 const bob = privateKeyWrapper('//Bob');101 const bob = privateKey('//Bob');128 const charlie = privateKeyWrapper('//Charlie');102 const charlie = privateKey('//Charlie');129103130 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));104 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));131 await submitTransactionAsync(alice, addAdminTx);105 await submitTransactionAsync(alice, addAdminTx);138 });112 });139 });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 });140});133});141134