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

difftreelog

Fix tests

Max Andreev2022-12-09parent: #fb2c7d6.patch.diff
in: master

4 files changed

modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
1import {IKeyringPair} from '@polkadot/types/types';1import {IKeyringPair} from '@polkadot/types/types';
2import {Pallets} from '../util';2import {Pallets} from '../util';
3import {expect, itEth, usingEthPlaygrounds} from './util';3import {CollectionLimits, expect, itEth, usingEthPlaygrounds} from './util';
44
55
6describe('Can set collection limits', () => {6describe('Can set collection limits', () => {
45 };45 };
46 46
47 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);47 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
48 await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();48 await collection.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
49 await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();49 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
50 await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();50 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
51 await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();51 await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
52 await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();52 await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
53 await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();53 await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
54 await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();54 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
55 await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();55 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
56 await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();56 await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
57 57
58 const data = (await helper.rft.getData(collectionId))!;58 const data = (await helper.rft.getData(collectionId))!;
59 expect(data.raw.limits).to.deep.eq(expectedLimits);59 expect(data.raw.limits).to.deep.eq(expectedLimits);
85 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);85 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);
86 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);86 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
87 await expect(collectionEvm.methods87 await expect(collectionEvm.methods
88 .setCollectionLimit('badLimit', '1')88 .setCollectionLimit(20, true, 1)
89 .call()).to.be.rejectedWith('unknown limit "badLimit"');89 .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');
90 90
91 await expect(collectionEvm.methods91 await expect(collectionEvm.methods
92 .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)92 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, BigInt(Number.MAX_SAFE_INTEGER))
93 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);93 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
94 94
95 await expect(collectionEvm.methods95 await expect(collectionEvm.methods
96 .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)96 .setCollectionLimit(CollectionLimits.TransferEnabled, true, 3)
97 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);97 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
98 }));98 }));
99});99});
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(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
111 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
112 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
113 await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
114 await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
115 await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
116 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
117 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
118 await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, 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);
277 }227 }
278 });228 });
279
280 itEth('(!negative test!) Set limits', async ({helper}) => {
281
282 const invalidLimits = {
283 accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
284 transfersEnabled: 3,
285 };
286
287 const owner = await helper.eth.createAccountWithBalance(donor);
288 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
290 await expect(collectionEvm.methods
291 .setCollectionLimit(20, true, '1')
292 .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');
293
294 await expect(collectionEvm.methods
295 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
296 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
297
298 await expect(collectionEvm.methods
299 .setCollectionLimit(CollectionLimits.TransferEnabled, true, invalidLimits.transfersEnabled)
300 .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
301 });
302
303
304
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(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
152 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
153 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
154 await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
155 await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
156 await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
157 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
158 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
159 await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, 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(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
302 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
303
304 await expect(collectionEvm.methods
305 .setCollectionLimit(CollectionLimits.TransferEnabled, true, 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(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
184 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
185 await collection.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
186 await collection.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
187 await collection.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
188 await collection.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
189 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
190 await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
191 await collection.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, 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(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
334 .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
335
336 await expect(collectionEvm.methods
337 .setCollectionLimit(CollectionLimits.TransferEnabled, true, 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);