git.delta.rocks / unique-network / refs/commits / c803bd5800f0

difftreelog

Merge pull request #150 from usetech-llc/feature/NFTPAR-118_Collection_Limits

str-mv2021-06-01parents: #172f80a #b398412.patch.diff
in: master
Add tests for setCollectionLimits

1 file changed

modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
29const sponsoredDataSize = 0;29const sponsoredDataSize = 0;
30const sponsoredMintSize = 0;30const sponsoredMintSize = 0;
31const sponsorTimeout = 1;31const sponsorTimeout = 1;
32const tokenLimit = 1;32const tokenLimit = 10;
3333
34describe('setCollectionLimits positive', () => {34describe('setCollectionLimits positive', () => {
35 let tx;35 let tx;
70 });70 });
71 });71 });
72
73 it('Set the same token limit twice', async () => {
74 await usingApi(async (api: ApiPromise) => {
75
76 let collectionLimits = {
77 AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
78 SponsoredMintSize: sponsoredDataSize,
79 TokenLimit: tokenLimit,
80 SponsorTimeout: sponsorTimeout,
81 OwnerCanTransfer: true,
82 OwnerCanDestroy: true
83 };
84
85 // The first time
86 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;
93
94 // The second time
95 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;
102
103 // tslint:disable-next-line:no-unused-expression
104 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 });
110
72});111});
73112
166 });205 });
167 });206 });
207
208 it('Setting the higher token limit fails', async () => {
209 await usingApi(async (api: ApiPromise) => {
210
211 const collectionId = await createCollectionExpectSuccess();
212 let collectionLimits = {
213 AccountTokenOwnershipLimit: accountTokenOwnershipLimit,
214 SponsoredMintSize: sponsoredDataSize,
215 TokenLimit: tokenLimit,
216 SponsorTimeout: sponsorTimeout,
217 OwnerCanTransfer: true,
218 OwnerCanDestroy: true
219 };
220
221 // The first time
222 await setCollectionLimitsExpectSuccess(alice, collectionId, collectionLimits);
223
224 // The second time - higher token limit
225 collectionLimits.TokenLimit += 1;
226 await setCollectionLimitsExpectFailure(alice, collectionId, collectionLimits);
227 });
228 });
229
168});230});
169231