git.delta.rocks / unique-network / refs/commits / 9bfc203a27ca

difftreelog

source

tests/src/setMintPermission.test.ts3.9 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import {IKeyringPair} from '@polkadot/types/types';7import privateKey from './substrate/privateKey';8import usingApi from './substrate/substrate-api';9import {10  addToAllowListExpectSuccess,11  createCollectionExpectSuccess,12  createItemExpectFailure,13  createItemExpectSuccess,14  destroyCollectionExpectSuccess,15  enableAllowListExpectSuccess,16  findNotExistingCollection,17  setMintPermissionExpectFailure,18  setMintPermissionExpectSuccess,19  addCollectionAdminExpectSuccess,20} from './util/helpers';2122describe('Integration Test setMintPermission', () => {23  let alice: IKeyringPair;24  let bob: IKeyringPair;2526  before(async () => {27    await usingApi(async () => {28      alice = privateKey('//Alice');29      bob = privateKey('//Bob');30    });31  });3233  it('ensure allow-listed non-privileged address can mint tokens', async () => {34    await usingApi(async () => {35      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});36      await enableAllowListExpectSuccess(alice, collectionId);37      await setMintPermissionExpectSuccess(alice, collectionId, true);38      await addToAllowListExpectSuccess(alice, collectionId, bob.address);3940      await createItemExpectSuccess(bob, collectionId, 'NFT');41    });42  });4344  it('can be enabled twice', async () => {45    await usingApi(async () => {46      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});47      await setMintPermissionExpectSuccess(alice, collectionId, true);48      await setMintPermissionExpectSuccess(alice, collectionId, true);49    });50  });5152  it('can be disabled twice', async () => {53    await usingApi(async () => {54      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});55      await setMintPermissionExpectSuccess(alice, collectionId, true);56      await setMintPermissionExpectSuccess(alice, collectionId, false);57      await setMintPermissionExpectSuccess(alice, collectionId, false);58    });59  });60});6162describe('Negative Integration Test setMintPermission', () => {63  let alice: IKeyringPair;64  let bob: IKeyringPair;6566  before(async () => {67    await usingApi(async () => {68      alice = privateKey('//Alice');69      bob = privateKey('//Bob');70    });71  });7273  it('fails on not existing collection', async () => {74    await usingApi(async (api) => {75      const nonExistingCollection = await findNotExistingCollection(api);76      await setMintPermissionExpectFailure(alice, nonExistingCollection, true);77    });78  });7980  it('fails on removed collection', async () => {81    await usingApi(async () => {82      const removedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});83      await destroyCollectionExpectSuccess(removedCollectionId);8485      await setMintPermissionExpectFailure(alice, removedCollectionId, true);86    });87  });8889  it('fails when not collection owner tries to set mint status', async () => {90    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});91    await enableAllowListExpectSuccess(alice, collectionId);92    await setMintPermissionExpectFailure(bob, collectionId, true);93  });9495  it('Collection admin fails on set', async () => {96    await usingApi(async () => {97      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});98      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);99      await setMintPermissionExpectFailure(bob, collectionId, true);100    });101  });102103  it('ensure non-allow-listed non-privileged address can\'t mint tokens', async () => {104    await usingApi(async () => {105      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});106      await enableAllowListExpectSuccess(alice, collectionId);107      await setMintPermissionExpectSuccess(alice, collectionId, true);108109      await createItemExpectFailure(bob, collectionId, 'NFT');110    });111  });112});