git.delta.rocks / unique-network / refs/commits / 68096799e125

difftreelog

source

tests/src/setMintPermission.test.ts2.4 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  let collectionId: number;20  before(async () => {21    await usingApi(async () => {22      alice = privateKey('//Alice');23      bob = privateKey('//Bob');2425      collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });26    });27  });2829  it('execute setMintPermission', async () => {30    await usingApi(async () => {31      await enableWhiteListExpectSuccess(alice, collectionId);32      await setMintPermissionExpectSuccess(alice, collectionId, true);33    });34  });3536  it('ensure white-listed non-privileged address can mint tokens', async () => {37    await usingApi(async () => {38      await addToWhiteListExpectSuccess(alice, collectionId, bob.address);39      await createItemExpectSuccess(bob, collectionId, 'NFT');40    });41  });42});4344describe('Negative Integration Test setMintPermission', () => {45  let alice: IKeyringPair;46  let bob: IKeyringPair;4748  before(async () => {49    await usingApi(async () => {50      alice = privateKey('//Alice');51      bob = privateKey('//Bob');52    });53  });5455  it('fails on not existing collection', async () => {56    await usingApi(async (api) => {57      const nonExistingCollection = await findNotExistingCollection(api);58      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);59    });60  });6162  it('fails on removed collection', async () => {63    await usingApi(async () => {64      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });65      await destroyCollectionExpectSuccess(removedCollectionId);6667      await setMintPermissionExpectFailure(alice, removedCollectionId, true);68    });69  });7071  it('fails when not collection owner tries to set mint status', async () => {72    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });73    await enableWhiteListExpectSuccess(alice, collectionId);74    await setMintPermissionExpectFailure(bob, collectionId, true);75  });76});