git.delta.rocks / unique-network / refs/commits / 470ffd5ce9b5

difftreelog

source

js-packages/tests/eth/destroyCollection.test.ts2.9 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import type {IKeyringPair} from '@polkadot/types/types';18import {Pallets} from '@unique/test-utils/util.js';19import {expect, itEth, usingEthPlaygrounds} from '@unique/test-utils/eth/util.js';20import type {TCollectionMode} from '@unique-nft/playgrounds/types.js';21import {CreateCollectionData} from '@unique/test-utils/eth/types.js';2223describe('Destroy Collection from EVM', function() {24  let donor: IKeyringPair;25  const testCases = [26    {case: 'rft' as const, params: ['Limits', 'absolutely anything', 'OLF', 'rft'], requiredPallets: [Pallets.ReFungible]},27    {case: 'nft' as const, params: ['Limits', 'absolutely anything', 'OLF', 'nft'], requiredPallets: [Pallets.NFT]},28    {case: 'ft' as const, params: ['Limits', 'absolutely anything', 'OLF', 'ft', 18], requiredPallets: [Pallets.Fungible]},29  ];3031  before(async function() {32    await usingEthPlaygrounds(async (_, privateKey) => {33      donor = await privateKey({url: import.meta.url});34    });35  });3637  testCases.map((testCase) =>38    itEth.ifWithPallets(`Cannot burn non-owned or non-existing collection ${testCase.case}`, testCase.requiredPallets, async ({helper}) => {39      const owner = await helper.eth.createAccountWithBalance(donor);40      const signer = await helper.eth.createAccountWithBalance(donor);4142      const unexistedCollection = helper.ethAddress.fromCollectionId(1000000);4344      const collectionHelpers = await helper.ethNativeContract.collectionHelpers(signer);45      const {collectionAddress} = await helper.eth.createCollection(owner, new CreateCollectionData(...testCase.params as [string, string, string, TCollectionMode, number?])).send();46      // cannot burn collec47      await expect(collectionHelpers.methods48        .destroyCollection(collectionAddress)49        .send({from: signer})).to.be.rejected;5051      await expect(collectionHelpers.methods52        .destroyCollection(unexistedCollection)53        .send({from: signer})).to.be.rejected;5455      expect(await collectionHelpers.methods56        .isCollectionExist(unexistedCollection)57        .call()).to.be.false;5859      expect(await collectionHelpers.methods60        .isCollectionExist(collectionAddress)61        .call()).to.be.true;62    }));63});