git.delta.rocks / unique-network / refs/commits / 55ff5a901dfa

difftreelog

tests: ensure non-WL address can't mint tokens

Yaroslav Bolyukin2021-02-01parent: #0d78fdd.patch.diff
in: master

1 file changed

modifiedtests/src/setMintPermission.test.tsdiffbeforeafterboth
before · tests/src/setMintPermission.test.ts
1import { IKeyringPair } from '@polkadot/types/types';2import privateKey from './substrate/privateKey';3import usingApi from './substrate/substrate-api';4import {5  addToWhiteListExpectSuccess,6  createCollectionExpectSuccess,7  createItemExpectSuccess,8  destroyCollectionExpectSuccess,9  enableWhiteListExpectSuccess,10  findNotExistingCollection,11  setMintPermissionExpectFailure,12  setMintPermissionExpectSuccess,13} from './util/helpers';1415describe('Integration Test setMintPermission', () => {16  let alice: IKeyringPair;17  let bob: IKeyringPair;1819  before(async () => {20    await usingApi(async () => {21      alice = privateKey('//Alice');22      bob = privateKey('//Bob');23    });24  });2526  it('ensure white-listed non-privileged address can mint tokens', async () => {27    await usingApi(async () => {28      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });29      await enableWhiteListExpectSuccess(alice, collectionId);30      await setMintPermissionExpectSuccess(alice, collectionId, true);31      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);3233      await createItemExpectSuccess(bob, collectionId, 'NFT');34    });35  });36});3738describe('Negative Integration Test setMintPermission', () => {39  let alice: IKeyringPair;40  let bob: IKeyringPair;4142  before(async () => {43    await usingApi(async () => {44      alice = privateKey('//Alice');45      bob = privateKey('//Bob');46    });47  });4849  it('fails on not existing collection', async () => {50    await usingApi(async (api) => {51      const nonExistingCollection = await findNotExistingCollection(api);52      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);53    });54  });5556  it('fails on removed collection', async () => {57    await usingApi(async () => {58      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });59      await destroyCollectionExpectSuccess(removedCollectionId);6061      await setMintPermissionExpectFailure(alice, removedCollectionId, true);62    });63  });6465  it('fails when not collection owner tries to set mint status', async () => {66    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });67    await enableWhiteListExpectSuccess(alice, collectionId);68    await setMintPermissionExpectFailure(bob, collectionId, true);69  });70});
after · tests/src/setMintPermission.test.ts
1import { IKeyringPair } from '@polkadot/types/types';2import privateKey from './substrate/privateKey';3import usingApi from './substrate/substrate-api';4import {5  addToWhiteListExpectSuccess,6  createCollectionExpectSuccess,7  createItemExpectFailure,8  createItemExpectSuccess,9  destroyCollectionExpectSuccess,10  enableWhiteListExpectSuccess,11  findNotExistingCollection,12  setMintPermissionExpectFailure,13  setMintPermissionExpectSuccess,14} from './util/helpers';1516describe('Integration Test setMintPermission', () => {17  let alice: IKeyringPair;18  let bob: IKeyringPair;1920  before(async () => {21    await usingApi(async () => {22      alice = privateKey('//Alice');23      bob = privateKey('//Bob');24    });25  });2627  it('ensure white-listed non-privileged address can mint tokens', async () => {28    await usingApi(async () => {29      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });30      await enableWhiteListExpectSuccess(alice, collectionId);31      await setMintPermissionExpectSuccess(alice, collectionId, true);32      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);3334      await createItemExpectSuccess(bob, collectionId, 'NFT');35    });36  });3738  it('ensure non-white-listed non-privileged address can\'t mint tokens', async () => {39    await usingApi(async () => {40      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });41      await enableWhiteListExpectSuccess(alice, collectionId);42      await setMintPermissionExpectSuccess(alice, collectionId, true);4344      await createItemExpectFailure(bob, collectionId, 'NFT');45    });46  });47});4849describe('Negative Integration Test setMintPermission', () => {50  let alice: IKeyringPair;51  let bob: IKeyringPair;5253  before(async () => {54    await usingApi(async () => {55      alice = privateKey('//Alice');56      bob = privateKey('//Bob');57    });58  });5960  it('fails on not existing collection', async () => {61    await usingApi(async (api) => {62      const nonExistingCollection = await findNotExistingCollection(api);63      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);64    });65  });6667  it('fails on removed collection', async () => {68    await usingApi(async () => {69      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });70      await destroyCollectionExpectSuccess(removedCollectionId);7172      await setMintPermissionExpectFailure(alice, removedCollectionId, true);73    });74  });7576  it('fails when not collection owner tries to set mint status', async () => {77    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });78    await enableWhiteListExpectSuccess(alice, collectionId);79    await setMintPermissionExpectFailure(bob, collectionId, true);80  });81});