git.delta.rocks / unique-network / refs/commits / 7d308448d30d

difftreelog

Remove duplicated properties tests

Max Andreev2022-12-22parent: #0147f01.patch.diff
in: master

1 file changed

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
82 {method: 'deleteCollectionProperties', mode: 'ft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},82 {method: 'deleteCollectionProperties', mode: 'ft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},
83 {method: 'deleteCollectionProperty', mode: 'nft' as const, methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]}, 83 {method: 'deleteCollectionProperty', mode: 'nft' as const, methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]},
84 ].map(testCase => 84 ].map(testCase =>
85 itEth(`Collection properties can be deleted: ${testCase.method}() for ${testCase.mode}`, async({helper}) => {85 itEth.ifWithPallets(`Collection properties can be deleted: ${testCase.method}() for ${testCase.mode}`, testCase.mode === 'rft' ? [Pallets.ReFungible] : [], async({helper}) => {
86 const properties = [86 const properties = [
87 {key: 'testKey1', value: 'testValue1'},87 {key: 'testKey1', value: 'testValue1'},
88 {key: 'testKey2', value: 'testValue2'},88 {key: 'testKey2', value: 'testValue2'},
221 }));220 }));
222});221});
223
224describe('EVM collection property', () => {
225 let donor: IKeyringPair;
226
227 before(async function() {
228 await usingEthPlaygrounds(async (_helper, privateKey) => {
229 donor = await privateKey({filename: __filename});
230 });
231 });
232
233 [
234 {case: 'nft' as const},
235 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
236 {case: 'ft' as const},
237 ].map(testCase =>
238 itEth.ifWithPallets(`can set/read properties ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
239 const collection = await helper[testCase.case].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
240
241 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
242 await collection.addAdmin(donor, {Ethereum: sender});
243
244 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
245 const contract = helper.ethNativeContract.collection(collectionAddress, testCase.case, sender);
246
247 const keys = ['key0', 'key1'];
248
249 const writeProperties = [
250 helper.ethProperty.property(keys[0], 'value0'),
251 helper.ethProperty.property(keys[1], 'value1'),
252 ];
253
254 await contract.methods.setCollectionProperties(writeProperties).send();
255 const readProperties = await contract.methods.collectionProperties([keys[0], keys[1]]).call();
256 expect(readProperties).to.be.like(writeProperties);
257 }));
258
259 [
260 {case: 'nft' as const},
261 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
262 {case: 'ft' as const},
263 ].map(testCase =>
264 itEth.ifWithPallets(`can delete properties ${testCase.case}`, testCase.requiredPallets || [], async ({helper}) => {
265 const collection = await helper[testCase.case].mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});
266
267 const sender = await helper.eth.createAccountWithBalance(donor, 100n);
268 await collection.addAdmin(donor, {Ethereum: sender});
269
270 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
271 const contract = helper.ethNativeContract.collection(collectionAddress, testCase.case, sender);
272
273 const keys = ['key0', 'key1', 'key2', 'key3'];
274
275 {
276 const writeProperties = [
277 helper.ethProperty.property(keys[0], 'value0'),
278 helper.ethProperty.property(keys[1], 'value1'),
279 helper.ethProperty.property(keys[2], 'value2'),
280 helper.ethProperty.property(keys[3], 'value3'),
281 ];
282
283 await contract.methods.setCollectionProperties(writeProperties).send();
284 const readProperties = await contract.methods.collectionProperties([keys[0], keys[1], keys[2], keys[3]]).call();
285 expect(readProperties).to.be.like(writeProperties);
286 }
287
288 {
289 const expectedProperties = [
290 helper.ethProperty.property(keys[0], 'value0'),
291 helper.ethProperty.property(keys[1], 'value1'),
292 ];
293
294 await contract.methods.deleteCollectionProperties([keys[2], keys[3]]).send();
295 const readProperties = await contract.methods.collectionProperties([]).call();
296 expect(readProperties).to.be.like(expectedProperties);
297 }
298 }));
299});
300222