From 65e4349bf66d6adece5300757993b621f2c5c51b Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Fri, 19 Feb 2021 20:58:40 +0000 Subject: [PATCH] tests: add setCollectionLimits helpers Signed-off-by: Yaroslav Bolyukin (cherry picked from commit 94a4122205b94c771af170233121c5cdc6d3e60c) --- --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -295,6 +295,36 @@ }); } +export async function queryCollectionLimits(collectionId: number) { + return await usingApi(async (api) => { + return ((await api.query.nft.collection(collectionId)).toJSON() as any).Limits; + }); +} + +export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) { + await usingApi(async (api) => { + const oldLimits = await queryCollectionLimits(collectionId); + const newLimits = { ...oldLimits as any, ...limits }; + const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits); + const events = await submitTransactionAsync(sender, tx); + const result = getGenericResult(events); + + expect(result.success).to.be.true; + }); +} + +export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) { + await usingApi(async (api) => { + const oldLimits = await queryCollectionLimits(collectionId); + const newLimits = { ...oldLimits as any, ...limits }; + const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits); + const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected; + const result = getGenericResult(events); + + expect(result.success).to.be.false; + }); +} + export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) { await usingApi(async (api) => { -- gitstuff