From a842c5decfd8e953951066a1855f6fcb896d1eb5 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 05 Mar 2021 11:05:09 +0000 Subject: [PATCH] tests: add failing tests for bulk mint overfow --- --- a/tests/src/createMultipleItems.test.ts +++ b/tests/src/createMultipleItems.test.ts @@ -11,7 +11,9 @@ import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, + getGenericResult, IReFungibleTokenDataType, + setCollectionLimitsExpectSuccess, } from './util/helpers'; chai.use(chaiAsPromised); @@ -92,6 +94,25 @@ expect(token3Data.VariableData.toString()).to.be.equal('0x33'); }); }); + + it('Can mint amount of items equals to collection limits', async () => { + await usingApi(async (api) => { + const alice = privateKey('//Alice'); + + const collectionId = await createCollectionExpectSuccess(); + await setCollectionLimitsExpectSuccess(alice, collectionId, { + TokenLimit: 2, + }); + const args = [ + { nft: ['A', 'A'] }, + { nft: ['B', 'B'] }, + ]; + const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, alice.address, args); + const events = await submitTransactionAsync(alice, createMultipleItemsTx); + const result = getGenericResult(events); + expect(result.success).to.be.true; + }); + }); }); describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => { @@ -175,4 +196,21 @@ await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected; }); }); + + it('Fails when minting tokens exceeds collectionLimits amount', async () => { + await usingApi(async (api) => { + const alice = privateKey('//Alice'); + + const collectionId = await createCollectionExpectSuccess(); + await setCollectionLimitsExpectSuccess(alice, collectionId, { + TokenLimit: 1, + }); + const args = [ + { nft: ['A', 'A'] }, + { nft: ['B', 'B'] }, + ]; + const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, alice.address, args); + await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected; + }); + }); }); -- gitstuff