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

difftreelog

Combine evm collection limits tests

Max Andreev2022-12-07parent: #8a193aa.patch.diff
in: master

4 files changed

addedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
79 expect(await collection.methods.description().call()).to.deep.equal(description);79 expect(await collection.methods.description().call()).to.deep.equal(description);
80 });80 });
81
82 itEth('Set limits', async ({helper}) => {
83 const owner = await helper.eth.createAccountWithBalance(donor);
84 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');
85 const limits = {
86 accountTokenOwnershipLimit: 1000,
87 sponsoredDataSize: 1024,
88 sponsoredDataRateLimit: 30,
89 tokenLimit: 1000000,
90 sponsorTransferTimeout: 6,
91 sponsorApproveTimeout: 6,
92 ownerCanTransfer: 0,
93 ownerCanDestroy: 0,
94 transfersEnabled: 0,
95 };
96
97 const expectedLimits = {
98 accountTokenOwnershipLimit: 1000,
99 sponsoredDataSize: 1024,
100 sponsoredDataRateLimit: 30,
101 tokenLimit: 1000000,
102 sponsorTransferTimeout: 6,
103 sponsorApproveTimeout: 6,
104 ownerCanTransfer: false,
105 ownerCanDestroy: false,
106 transfersEnabled: false,
107 };
108
109 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
110 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
111 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
112 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
113 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
114 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
115 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
116 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
117 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
118 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
119
120 const data = (await helper.rft.getData(collectionId))!;
121 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
122 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
123 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
124 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
125 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
126 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
127 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
128 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
129 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
130 });
13181
132 itEth('Collection address exist', async ({helper}) => {82 itEth('Collection address exist', async ({helper}) => {
133 const owner = await helper.eth.createAccountWithBalance(donor);83 const owner = await helper.eth.createAccountWithBalance(donor);
276 }226 }
277 });227 });
278
279 itEth('(!negative test!) Set limits', async ({helper}) => {
280
281 const invalidLimits = {
282 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
283 transfersEnabled: 3,
284 };
285
286 const owner = await helper.eth.createAccountWithBalance(donor);
287 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
288 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
289 await expect(collectionEvm.methods
290 .setCollectionLimit('badLimit', '1')
291 .call()).to.be.rejectedWith('unknown limit "badLimit"');
292
293 await expect(collectionEvm.methods
294 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
295 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
296
297 await expect(collectionEvm.methods
298 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
299 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
300 });
301
302
303
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
120 expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);120 expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);
121 });121 });
122
123 itEth('Set limits', async ({helper}) => {
124 const owner = await helper.eth.createAccountWithBalance(donor);
125 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');
126 const limits = {
127 accountTokenOwnershipLimit: 1000,
128 sponsoredDataSize: 1024,
129 sponsoredDataRateLimit: 30,
130 tokenLimit: 1000000,
131 sponsorTransferTimeout: 6,
132 sponsorApproveTimeout: 6,
133 ownerCanTransfer: 0,
134 ownerCanDestroy: 0,
135 transfersEnabled: 0,
136 };
137
138 const expectedLimits = {
139 accountTokenOwnershipLimit: 1000,
140 sponsoredDataSize: 1024,
141 sponsoredDataRateLimit: 30,
142 tokenLimit: 1000000,
143 sponsorTransferTimeout: 6,
144 sponsorApproveTimeout: 6,
145 ownerCanTransfer: false,
146 ownerCanDestroy: false,
147 transfersEnabled: false,
148 };
149
150 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
151 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
152 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
153 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
154 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
155 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
156 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
157 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
158 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
159 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
160
161 const data = (await helper.rft.getData(collectionId))!;
162 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
163 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
164 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
165 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
166 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
167 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
168 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
169 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
170 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
171 });
172122
173 itEth('Collection address exist', async ({helper}) => {123 itEth('Collection address exist', async ({helper}) => {
174 const owner = await helper.eth.createAccountWithBalance(donor);124 const owner = await helper.eth.createAccountWithBalance(donor);
287 }237 }
288 });238 });
289
290 itEth('(!negative test!) Set limits', async ({helper}) => {
291 const invalidLimits = {
292 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
293 transfersEnabled: 3,
294 };
295
296 const owner = await helper.eth.createAccountWithBalance(donor);
297 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
298 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
299
300 await expect(collectionEvm.methods
301 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
302 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
303
304 await expect(collectionEvm.methods
305 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
306 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
307 });
308239
309 itEth('destroyCollection', async ({helper}) => {240 itEth('destroyCollection', async ({helper}) => {
310 const owner = await helper.eth.createAccountWithBalance(donor);241 const owner = await helper.eth.createAccountWithBalance(donor);
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
152 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));152 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
153 });153 });
154
155 itEth('Set limits', async ({helper}) => {
156 const owner = await helper.eth.createAccountWithBalance(donor);
157 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'INSI');
158 const limits = {
159 accountTokenOwnershipLimit: 1000,
160 sponsoredDataSize: 1024,
161 sponsoredDataRateLimit: 30,
162 tokenLimit: 1000000,
163 sponsorTransferTimeout: 6,
164 sponsorApproveTimeout: 6,
165 ownerCanTransfer: 0,
166 ownerCanDestroy: 0,
167 transfersEnabled: 0,
168 };
169
170 const expectedLimits = {
171 accountTokenOwnershipLimit: 1000,
172 sponsoredDataSize: 1024,
173 sponsoredDataRateLimit: 30,
174 tokenLimit: 1000000,
175 sponsorTransferTimeout: 6,
176 sponsorApproveTimeout: 6,
177 ownerCanTransfer: false,
178 ownerCanDestroy: false,
179 transfersEnabled: false,
180 };
181
182 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
183 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
184 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
185 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
186 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
187 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
188 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
189 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
190 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
191 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
192
193 const data = (await helper.rft.getData(collectionId))!;
194 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
195 expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
196 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
197 expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
198 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
199 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
200 expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
201 expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
202 expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
203 });
204154
205 itEth('Collection address exist', async ({helper}) => {155 itEth('Collection address exist', async ({helper}) => {
206 const owner = await helper.eth.createAccountWithBalance(donor);156 const owner = await helper.eth.createAccountWithBalance(donor);
319 }269 }
320 });270 });
321271
322 itEth('(!negative test!) Set limits', async ({helper}) => {
323 const invalidLimits = {
324 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
325 transfersEnabled: 3,
326 };
327
328 const owner = await helper.eth.createAccountWithBalance(donor);
329 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
330 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
331
332 await expect(collectionEvm.methods
333 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
334 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
335
336 await expect(collectionEvm.methods
337 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
338 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
339 });
340
341 itEth('destroyCollection', async ({helper}) => {272 itEth('destroyCollection', async ({helper}) => {
342 const owner = await helper.eth.createAccountWithBalance(donor);273 const owner = await helper.eth.createAccountWithBalance(donor);