git.delta.rocks / unique-network / refs/commits / 23a018e7c903

difftreelog

source

tests/src/collision-tests/tokenLimitsOff.test.ts3.0 KiBsourcehistory
1/* broken by design2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate45import { IKeyringPair } from '@polkadot/types/types';6import BN from 'bn.js';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from '../substrate/privateKey';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11import {12  addToAllowListExpectSuccess,13  createCollectionExpectSuccess,14  getCreateItemResult,15  setMintPermissionExpectSuccess,16  normalizeAccountId,17  waitNewBlocks,18} from '../util/helpers';1920chai.use(chaiAsPromised);21const expect = chai.expect;22let Alice: IKeyringPair;23let Bob: IKeyringPair;24let Ferdie: IKeyringPair;2526const accountTokenOwnershipLimit = 4;27const sponsoredMintSize = 4294967295;28const tokenLimit = 4;29const sponsorTimeout = 14400;30const ownerCanTransfer = false;31const ownerCanDestroy = false;3233before(async () => {34  await usingApi(async () => {35    Alice = privateKey('//Alice');36    Bob = privateKey('//Bob');37    Ferdie = privateKey('//Ferdie');38  });39});4041describe('Token limit exceeded collection: ', () => {42  // tslint:disable-next-line: max-line-length43  it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {44    await usingApi(async (api) => {45      const collectionId = await createCollectionExpectSuccess();46      await setMintPermissionExpectSuccess(Alice, collectionId, true);47      await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);48      await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);49      const setCollectionLim = api.tx.nft.setCollectionLimits(50        collectionId,51        {52          accountTokenOwnershipLimit,53          sponsoredMintSize,54          tokenLimit,55          // tslint:disable-next-line: object-literal-sort-keys56          sponsorTimeout,57          ownerCanTransfer,58          ownerCanDestroy,59        },60      );61      const subTx = await submitTransactionAsync(Alice, setCollectionLim);62      const subTxTesult = getCreateItemResult(subTx);63      // tslint:disable-next-line:no-unused-expression64      expect(subTxTesult.success).to.be.true;65      await waitNewBlocks(2);6667      const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];68      const mintItemOne = api.tx.nft69        .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);70      const mintItemTwo = api.tx.nft71        .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);72      await Promise.all([73        mintItemOne.signAndSend(Ferdie),74        mintItemTwo.signAndSend(Bob),75      ]);76      await waitNewBlocks(2);77      const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;78      expect(itemsListIndexAfter.toNumber()).to.be.equal(3);79      // TokenLimit = 4. The first transaction is successful. The second should fail.80      await waitNewBlocks(2);81    });82  });83});84*/