git.delta.rocks / unique-network / refs/commits / 92f89cb770f9

difftreelog

source

tests/src/setMintPermission.test.ts3.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  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('can be enabled twice', async () => {39    await usingApi(async () => {40      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });41      await setMintPermissionExpectSuccess(alice, collectionId, true);42      await setMintPermissionExpectSuccess(alice, collectionId, true);43    });44  });4546  it('can be disabled twice', async () => {47    await usingApi(async () => {48      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });49      await setMintPermissionExpectSuccess(alice, collectionId, true);50      await setMintPermissionExpectSuccess(alice, collectionId, false);51      await setMintPermissionExpectSuccess(alice, collectionId, false);52    });53  });54});5556describe('Negative Integration Test setMintPermission', () => {57  let alice: IKeyringPair;58  let bob: IKeyringPair;5960  before(async () => {61    await usingApi(async () => {62      alice = privateKey('//Alice');63      bob = privateKey('//Bob');64    });65  });6667  it('fails on not existing collection', async () => {68    await usingApi(async (api) => {69      const nonExistingCollection = await findNotExistingCollection(api);70      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);71    });72  });7374  it('fails on removed collection', async () => {75    await usingApi(async () => {76      const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });77      await destroyCollectionExpectSuccess(removedCollectionId);7879      await setMintPermissionExpectFailure(alice, removedCollectionId, true);80    });81  });8283  it('fails when not collection owner tries to set mint status', async () => {84    const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });85    await enableWhiteListExpectSuccess(alice, collectionId);86    await setMintPermissionExpectFailure(bob, collectionId, true);87  });8889  it('ensure non-white-listed non-privileged address can\'t mint tokens', async () => {90    await usingApi(async () => {91      const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });92      await enableWhiteListExpectSuccess(alice, collectionId);93      await setMintPermissionExpectSuccess(alice, collectionId, true);9495      await createItemExpectFailure(bob, collectionId, 'NFT');96    });97  });98});