git.delta.rocks / unique-network / refs/commits / 94a4122205b9

difftreelog

tests: add setCollectionLimits helpers

Yaroslav Bolyukin2021-02-19parent: #5d685ed.patch.diff
in: master

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
295 });295 });
296}296}
297
298export async function queryCollectionLimits(collectionId: number) {
299 return await usingApi(async (api) => {
300 return ((await api.query.nft.collection(collectionId)).toJSON() as any).Limits;
301 });
302}
303
304export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {
305 await usingApi(async (api) => {
306 const oldLimits = await queryCollectionLimits(collectionId);
307 const newLimits = { ...oldLimits as any, ...limits };
308 const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
309 const events = await submitTransactionAsync(sender, tx);
310 const result = getGenericResult(events);
311
312 expect(result.success).to.be.true;
313 });
314}
315
316export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
317 await usingApi(async (api) => {
318 const oldLimits = await queryCollectionLimits(collectionId);
319 const newLimits = { ...oldLimits as any, ...limits };
320 const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
321 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
322 const result = getGenericResult(events);
323
324 expect(result.success).to.be.false;
325 });
326}
297327
298export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {328export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {
299 await usingApi(async (api) => {329 await usingApi(async (api) => {