git.delta.rocks / unique-network / refs/commits / 0d78fddb4dad

difftreelog

source

tests/src/setMintPermission.test.ts2.3 KiBsourcehistory
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});