1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, lockCollection, mintNft} from './util/tx';56describe('integration test: lock collection', () => {7 const Alice = '//Alice';8 const Bob = '//Bob';9 const Max = 5;1011 let api: any;12 before(async function () {13 api = await getApiConnection();14 await requirePallets(this, [Pallets.RmrkCore]);15 });1617 it('lock collection', async () => {18 await createCollection(19 api,20 Alice,21 'test-metadata',22 null,23 'test-symbol',24 ).then(async (collectionId) => {25 await lockCollection(api, Alice, collectionId);26 });27 });2829 it('[negative] lock non-existing NFT collection', async () => {30 const tx = lockCollection(api, Alice, 99999);31 await expectTxFailure(/rmrkCore\.CollectionUnknown/, tx);32 });3334 it('[negative] lock not an owner NFT collection issuer', async () => {35 await createCollection(36 api,37 Alice,38 'test-metadata',39 null,40 'test-symbol',41 ).then(async (collectionId) => {42 const tx = lockCollection(api, Bob, collectionId);43 await expectTxFailure(/rmrkCore\.NoPermission/, tx);44 });45 });4647 it('lock collection with minting', async () => {48 await createCollection(49 api,50 Alice,51 'test-metadata',52 Max,53 'test-symbol',54 ).then(async (collectionId) => {55 for (let i = 0; i < 5; i++) {56 await mintNft(57 api,58 Alice,59 Alice,60 collectionId,61 'test-metadata',62 null,63 null,64 );65 }66 await lockCollection(api, Alice, collectionId, Max);67 });68 });6970 it('[negative] unable to mint NFT inside a locked collection', async () => {71 await createCollection(72 api,73 Alice,74 'test-metadata',75 Max,76 'test-symbol',77 ).then(async (collectionId) => {78 await lockCollection(api, Alice, collectionId);79 const tx = mintNft(80 api,81 Alice,82 Alice,83 collectionId,84 'test-metadata',85 null,86 null,87 );88 await expectTxFailure(/rmrkCore\.CollectionFullOrLocked/, tx);89 });90 });9192 it('[negative] unable to mint NFT inside a full collection', async () => {93 await createCollection(api, Alice, 'test-metadata', 1, 'test-symbol').then(async (collectionId) => {94 await mintNft(95 api,96 Alice,97 Alice,98 collectionId,99 'test-metadata',100 null,101 null,102 );103 const tx = mintNft(104 api,105 Alice,106 Alice,107 collectionId,108 'test-metadata',109 null,110 null,111 );112 await expectTxFailure(/rmrkCore\.CollectionFullOrLocked/, tx);113 });114 });115116 after(() => {117 api.disconnect();118 });119});