git.delta.rocks / unique-network / refs/commits / 0bee999418d1

difftreelog

CORE-238 Add change limits test

Trubnikov Sergey2022-04-06parent: #866bd05.patch.diff
in: master

1 file changed

modifiedtests/src/limits.test.tsdiffbeforeafterboth
400 await usingApi(async (api) => {400 await usingApi(async (api) => {
401 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});401 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
402 402
403 {403 { // Check that limits is undefined
404 const collection = await api.rpc.unique.collectionById(collectionId);404 const collection = await api.rpc.unique.collectionById(collectionId);
405 expect(collection.isSome).to.be.true;405 expect(collection.isSome).to.be.true;
406 const limits = collection.unwrap().limits;406 const limits = collection.unwrap().limits;
407 expect(limits).to.be.any;407 expect(limits).to.be.any;
408 408
409 // Check that limits is undefined
410 expect(limits.accountTokenOwnershipLimit.toHuman()).to.be.null;409 expect(limits.accountTokenOwnershipLimit.toHuman()).to.be.null;
411 expect(limits.sponsoredDataSize.toHuman()).to.be.null;410 expect(limits.sponsoredDataSize.toHuman()).to.be.null;
412 expect(limits.sponsoredDataRateLimit.toHuman()).to.be.null;411 expect(limits.sponsoredDataRateLimit.toHuman()).to.be.null;
418 expect(limits.transfersEnabled.toHuman()).to.be.null;417 expect(limits.transfersEnabled.toHuman()).to.be.null;
419 }418 }
420 419
421 {420 { // Check that limits is undefined for non-existent collection
422 const limits = await api.rpc.unique.effectiveCollectionLimits(11111);421 const limits = await api.rpc.unique.effectiveCollectionLimits(11111);
423 expect(limits.toHuman()).to.be.null;422 expect(limits.toHuman()).to.be.null;
424 }423 }
425 424
426 {425 { // Check that default values defined for collection limits
427 const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);426 const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);
428 expect(limitsOpt.isNone).to.be.false;427 expect(limitsOpt.isNone).to.be.false;
429 const limits = limitsOpt.unwrap();428 const limits = limitsOpt.unwrap();
439 expect(limits.transfersEnabled.toHuman()).to.be.true;438 expect(limits.transfersEnabled.toHuman()).to.be.true;
440 }439 }
440
441 { //Check the values for collection limits
442 await setCollectionLimitsExpectSuccess(alice, collectionId, {
443 accountTokenOwnershipLimit: 99_999,
444 sponsoredDataSize: 1024,
445 tokenLimit: 123,
446 transfersEnabled: false,
447 });
448
449 const limitsOpt = await api.rpc.unique.effectiveCollectionLimits(collectionId);
450 expect(limitsOpt.isNone).to.be.false;
451 const limits = limitsOpt.unwrap();
452
453 expect(limits.accountTokenOwnershipLimit.toHuman()).to.be.eq('99,999');
454 expect(limits.sponsoredDataSize.toHuman()).to.be.eq('1,024');
455 expect(limits.sponsoredDataRateLimit.toHuman()).to.be.eq('SponsoringDisabled');
456 expect(limits.tokenLimit.toHuman()).to.be.eq('123');
457 expect(limits.sponsorTransferTimeout.toHuman()).to.be.eq('5');
458 expect(limits.sponsorApproveTimeout.toHuman()).to.be.eq('5');
459 expect(limits.ownerCanTransfer.toHuman()).to.be.true;
460 expect(limits.ownerCanDestroy.toHuman()).to.be.true;
461 expect(limits.transfersEnabled.toHuman()).to.be.false;
462 }
441 });463 });
442 });464 });
443});465});