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

difftreelog

Add delete property negative tests

Max Andreev2022-12-12parent: #63d47c8.patch.diff
in: master

1 file changed

modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
240 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {240 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {
241 caller = await helper.eth.createAccountWithBalance(donor);241 caller = await helper.eth.createAccountWithBalance(donor);
242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);242 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);
243 // Caller an owner and not an admin, so he cannot set properties:243 // Caller not an owner and not an admin, so he cannot set properties:
244 // FIXME: Can setProperties as non owner and non admin244 // FIXME: Can setProperties as non owner and non admin
245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');245 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');
246 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;246 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;
264 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;264 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;
265265
266 // Props have not changed:266 // Props have not changed:
267 const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));
267 const actualProps = await collectionEvm.methods.properties(token.tokenId, ['testKey2']).call();268 const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();
268 expect(actualProps).to.deep.eq(tokenProps269 expect(actualProps).to.deep.eq(expectedProps);
269 .map(p => { return helper.ethProperty.property(p.key, p.value.toString());
270 }));
271 }));270 }));
272271
272 [
273 {method: 'deleteProperty', methodParams: ['testKey_2']}, // FIXME: the method is gone?
274 {method: 'deleteProperties', methodParams: [['testKey_2']]},
275 ].map(testCase =>
273 itEth('Cannot delete properties of non-owned collection', async () => {276 itEth('Cannot delete properties of non-owned collection', async ({helper}) => {
274277 caller = await helper.eth.createAccountWithBalance(donor);
278 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);
279 // Caller not an owner and not an admin, so he cannot set properties:
280 // FIXME: non owner and non admin can deleteProperties
281 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});
282 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');
283 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;
284
285 // Props have not changed:
286 const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));
287 const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();
288 expect(actualProps).to.deep.eq(expectedProps);
275 });289 }));
276290
277 itEth('Cannot delete non-existing properties', async () => {291 itEth('Cannot delete non-existing properties', async () => {
278292