difftreelog
Merge pull request #150 from usetech-llc/feature/NFTPAR-118_Collection_Limits
in: master
Add tests for setCollectionLimits
1 file changed
tests/src/setCollectionLimits.test.tsdiffbeforeafterboth29const sponsoredDataSize = 0;29const sponsoredDataSize = 0;30const sponsoredMintSize = 0;30const sponsoredMintSize = 0;31const sponsorTimeout = 1;31const sponsorTimeout = 1;32const tokenLimit = 1;32const tokenLimit = 10;333334describe('setCollectionLimits positive', () => {34describe('setCollectionLimits positive', () => {35 let tx;35 let tx;70 });70 });71 });71 });7273 it('Set the same token limit twice', async () => {74 await usingApi(async (api: ApiPromise) => {7576 let collectionLimits = {77 AccountTokenOwnershipLimit: accountTokenOwnershipLimit,78 SponsoredMintSize: sponsoredDataSize,79 TokenLimit: tokenLimit,80 SponsorTimeout: sponsorTimeout,81 OwnerCanTransfer: true,82 OwnerCanDestroy: true83 };8485 // The first time86 const tx1 = api.tx.nft.setCollectionLimits(87 collectionIdForTesting,88 collectionLimits,89 );90 const events1 = await submitTransactionAsync(alice, tx1);91 const result1 = getCreateItemResult(events1);92 const collectionInfo1 = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;9394 // The second time95 const tx2 = api.tx.nft.setCollectionLimits(96 collectionIdForTesting,97 collectionLimits,98 );99 const events2 = await submitTransactionAsync(alice, tx2);100 const result2 = getCreateItemResult(events2);101 const collectionInfo2 = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;102103 // tslint:disable-next-line:no-unused-expression104 expect(result1.success).to.be.true;105 expect(collectionInfo1.Limits.TokenLimit).to.be.equal(tokenLimit);106 expect(result2.success).to.be.true;107 expect(collectionInfo2.Limits.TokenLimit).to.be.equal(tokenLimit);108 });109 });11072});111});73112166 });205 });167 });206 });207208 it('Setting the higher token limit fails', async () => {209 await usingApi(async (api: ApiPromise) => {210211 const collectionId = await createCollectionExpectSuccess();212 let collectionLimits = {213 AccountTokenOwnershipLimit: accountTokenOwnershipLimit,214 SponsoredMintSize: sponsoredDataSize,215 TokenLimit: tokenLimit,216 SponsorTimeout: sponsorTimeout,217 OwnerCanTransfer: true,218 OwnerCanDestroy: true219 };220221 // The first time222 await setCollectionLimitsExpectSuccess(alice, collectionId, collectionLimits);223224 // The second time - higher token limit225 collectionLimits.TokenLimit += 1;226 await setCollectionLimitsExpectFailure(alice, collectionId, collectionLimits);227 });228 });229168});230});169231