git.delta.rocks / unique-network / refs/commits / 2df3f6b6e145

difftreelog

source

tests/src/.outdated/collision-tests/tokenLimitsOff.test.ts3.7 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.89// 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/>.1617/* broken by design18// substrate transactions are sequential, not parallel19// the order of execution is indeterminate2021import { IKeyringPair } from '@polkadot/types/types';22import BN from 'bn.js';23import chai from 'chai';24import chaiAsPromised from 'chai-as-promised';25import privateKey from '../substrate/privateKey';26import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';27import {28  addToAllowListExpectSuccess,29  createCollectionExpectSuccess,30  getCreateItemResult,31  setMintPermissionExpectSuccess,32  normalizeAccountId,33  waitNewBlocks,34} from '../util/helpers';3536chai.use(chaiAsPromised);37const expect = chai.expect;38let Alice: IKeyringPair;39let Bob: IKeyringPair;40let Ferdie: IKeyringPair;4142const accountTokenOwnershipLimit = 4;43const sponsoredMintSize = 4294967295;44const tokenLimit = 4;45const sponsorTimeout = 14400;46const ownerCanTransfer = false;47const ownerCanDestroy = false;4849before(async () => {50  await usingApi(async () => {51    Alice = privateKey('//Alice');52    Bob = privateKey('//Bob');53    Ferdie = privateKey('//Ferdie');54  });55});5657describe('Token limit exceeded collection: ', () => {58  // tslint:disable-next-line: max-line-length59  it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {60    await usingApi(async (api) => {61      const collectionId = await createCollectionExpectSuccess();62      await setMintPermissionExpectSuccess(Alice, collectionId, true);63      await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);64      await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);65      const setCollectionLim = api.tx.unique.setCollectionLimits(66        collectionId,67        {68          accountTokenOwnershipLimit,69          sponsoredMintSize,70          tokenLimit,71          // tslint:disable-next-line: object-literal-sort-keys72          sponsorTimeout,73          ownerCanTransfer,74          ownerCanDestroy,75        },76      );77      const subTx = await submitTransactionAsync(Alice, setCollectionLim);78      const subTxTesult = getCreateItemResult(subTx);79      // tslint:disable-next-line:no-unused-expression80      expect(subTxTesult.success).to.be.true;81      await waitNewBlocks(2);8283      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];84      const mintItemOne = api.tx.unique85        .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);86      const mintItemTwo = api.tx.unique87        .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);88      await Promise.all([89        mintItemOne.signAndSend(Ferdie),90        mintItemTwo.signAndSend(Bob),91      ]);92      await waitNewBlocks(2);93      const itemsListIndexAfter = await api.query.unique.itemListIndex(collectionId) as unknown as BN;94      expect(itemsListIndexAfter.toNumber()).to.be.equal(3);95      // TokenLimit = 4. The first transaction is successful. The second should fail.96      await waitNewBlocks(2);97    });98  });99});100*/