git.delta.rocks / unique-network / refs/commits / d41cda7482d4

difftreelog

source

tests/src/rmrk/lockCollection.test.ts2.7 KiBsourcehistory
1import {getApiConnection} from '../substrate/substrate-api';2import {expectTxFailure} from './util/helpers';3import {createCollection, lockCollection, mintNft} from './util/tx';45describe('integration test: lock collection', () => {6  const Alice = '//Alice';7  const Bob = '//Bob';8  const Max = 5;910  let api: any;11  before(async () => {12    api = await getApiConnection();13  });1415  it('lock collection', async () => {16    await createCollection(17      api,18      Alice,19      'test-metadata',20      null,21      'test-symbol',22    ).then(async (collectionId) => {23      await lockCollection(api, Alice, collectionId);24    });25  });2627  it('[negative] lock non-existing NFT collection', async () => {28    const tx = lockCollection(api, Alice, 99999);29    await expectTxFailure(/rmrkCore\.CollectionUnknown/, tx);30  });3132  it('[negative] lock not an owner NFT collection issuer', async () => {33    await createCollection(34      api,35      Alice,36      'test-metadata',37      null,38      'test-symbol',39    ).then(async (collectionId) => {40      const tx = lockCollection(api, Bob, collectionId);41      await expectTxFailure(/rmrkCore\.NoPermission/, tx);42    });43  });4445  it('lock collection with minting', async () => {46    await createCollection(47      api,48      Alice,49      'test-metadata',50      Max,51      'test-symbol',52    ).then(async (collectionId) => {53      for (let i = 0; i < 5; i++) {54        await mintNft(55          api,56          Alice,57          Alice,58          collectionId,59          'test-metadata',60          null,61          null,62        );63      }64      await lockCollection(api, Alice, collectionId, Max);65    });66  });6768  it('[negative] unable to mint NFT inside a locked collection', async () => {69    await createCollection(70      api,71      Alice,72      'test-metadata',73      Max,74      'test-symbol',75    ).then(async (collectionId) => {76      await lockCollection(api, Alice, collectionId);77      const tx = mintNft(78        api,79        Alice,80        Alice,81        collectionId,82        'test-metadata',83        null,84        null,85      );86      await expectTxFailure(/rmrkCore\.CollectionFullOrLocked/, tx);87    });88  });8990  it('[negative] unable to mint NFT inside a full collection', async () => {91    await createCollection(api, Alice, 'test-metadata', 1, 'test-symbol').then(async (collectionId) => {92      await mintNft(93        api,94        Alice,95        Alice,96        collectionId,97        'test-metadata',98        null,99        null,100      );101      const tx = mintNft(102        api,103        Alice,104        Alice,105        collectionId,106        'test-metadata',107        null,108        null,109      );110      await expectTxFailure(/rmrkCore\.CollectionFullOrLocked/, tx);111    });112  });113114  after(() => {115    api.disconnect();116  });117});