git.delta.rocks / unique-network / refs/commits / 6f1d8428d6e1

difftreelog

source

tests/src/mintModes.test.ts5.7 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  enableAllowListExpectSuccess,15  setMintPermissionExpectSuccess,16  addCollectionAdminExpectSuccess,17  disableAllowListExpectSuccess,18} from './util/helpers';1920describe('Integration Test public minting', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;2324  before(async () => {25    await usingApi(async () => {26      alice = privateKey('//Alice');27      bob = privateKey('//Bob');28    });29  });3031  it('If the AllowList mode is enabled, then the address added to the allowlist and not the owner or administrator can create tokens', async () => {32    await usingApi(async () => {33      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});34      await enableAllowListExpectSuccess(alice, collectionId);35      await setMintPermissionExpectSuccess(alice, collectionId, true);36      await addToAllowListExpectSuccess(alice, collectionId, bob.address);3738      await createItemExpectSuccess(bob, collectionId, 'NFT');39    });40  });4142  it('If the AllowList mode is enabled, address not included in allowlist that is regular user cannot create tokens', async () => {43    await usingApi(async () => {44      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});45      await enableAllowListExpectSuccess(alice, collectionId);46      await setMintPermissionExpectSuccess(alice, collectionId, true);47      await createItemExpectFailure(bob, collectionId, 'NFT');48    });49  });5051  it('If the AllowList mode is enabled, address not included in allowlist that is admin can create tokens', async () => {52    await usingApi(async () => {53      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});54      await enableAllowListExpectSuccess(alice, collectionId);55      await setMintPermissionExpectSuccess(alice, collectionId, true);56      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);57      await createItemExpectSuccess(bob, collectionId, 'NFT');58    });59  });6061  it('If the AllowList mode is enabled, address not included in allowlist that is owner can create tokens', async () => {62    await usingApi(async () => {63      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});64      await enableAllowListExpectSuccess(alice, collectionId);65      await setMintPermissionExpectSuccess(alice, collectionId, true);66      await createItemExpectSuccess(alice, collectionId, 'NFT');67    });68  });6970  it('If the AllowList mode is disabled, owner can create tokens', async () => {71    await usingApi(async () => {72      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});73      await disableAllowListExpectSuccess(alice, collectionId);74      await setMintPermissionExpectSuccess(alice, collectionId, true);75      await createItemExpectSuccess(alice, collectionId, 'NFT');76    });77  });7879  it('If the AllowList mode is disabled, collection admin can create tokens', async () => {80    await usingApi(async () => {81      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});82      await disableAllowListExpectSuccess(alice, collectionId);83      await setMintPermissionExpectSuccess(alice, collectionId, true);84      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);85      await createItemExpectSuccess(bob, collectionId, 'NFT');86    });87  });8889  it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {90    await usingApi(async () => {91      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});92      await disableAllowListExpectSuccess(alice, collectionId);93      await setMintPermissionExpectSuccess(alice, collectionId, true);94      await createItemExpectFailure(bob, collectionId, 'NFT');95    });96  });97});9899describe('Integration Test private minting', () => {100  let alice: IKeyringPair;101  let bob: IKeyringPair;102103  before(async () => {104    await usingApi(async () => {105      alice = privateKey('//Alice');106      bob = privateKey('//Bob');107    });108  });109110  it('Address that is the not owner or not admin cannot create tokens', async () => {111    await usingApi(async () => {112      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});113      await enableAllowListExpectSuccess(alice, collectionId);114      await setMintPermissionExpectSuccess(alice, collectionId, false);115      await addToAllowListExpectSuccess(alice, collectionId, bob.address);116      await createItemExpectFailure(bob, collectionId, 'NFT');117    });118  });119120  it('Address that is collection owner can create tokens', async () => {121    await usingApi(async () => {122      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});123      await disableAllowListExpectSuccess(alice, collectionId);124      await setMintPermissionExpectSuccess(alice, collectionId, false);125      await createItemExpectSuccess(alice, collectionId, 'NFT');126    });127  });128129  it('Address that is admin can create tokens', async () => {130    await usingApi(async () => {131      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});132      await disableAllowListExpectSuccess(alice, collectionId);133      await setMintPermissionExpectSuccess(alice, collectionId, false);134      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);135      await createItemExpectSuccess(bob, collectionId, 'NFT');136    });137  });138});