git.delta.rocks / unique-network / refs/commits / 86d26e3a07ad

difftreelog

source

tests/src/rmrk/lockCollection.test.ts2.8 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          null62        );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        null85      );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(92      async (collectionId) => {93        await mintNft(94          api,95          Alice,96          Alice,97          collectionId,98          "test-metadata",99          null,100          null101        );102        const tx = mintNft(103          api,104          Alice,105          Alice,106          collectionId,107          "test-metadata",108          null,109          null110        );111        await expectTxFailure(/rmrkCore\.CollectionFullOrLocked/, tx);112      }113    );114  });115116  after(() => {117    api.disconnect();118  });119});