From 8a193aa1d0a5fb805905f1cf71172ce5b8d6544e Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Wed, 07 Dec 2022 07:50:28 +0000 Subject: [PATCH] cannot delete prop of non-owned collections --- --- a/tests/src/eth/collectionProperties.test.ts +++ b/tests/src/eth/collectionProperties.test.ts @@ -72,7 +72,7 @@ {method: 'deleteCollectionProperties', methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]}, {method: 'deleteCollectionProperty', methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]}, ].map(testCase => - itEth(`Collection properties can be deleted: ${testCase.method}`, async({helper}) => { + itEth(`Collection properties can be deleted: ${testCase.method}()`, async({helper}) => { const properties = [ {key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}, @@ -92,8 +92,26 @@ expect(raw.properties.length).to.equal(testCase.expectedProps.length); expect(raw.properties).to.deep.equal(testCase.expectedProps); })); + - // TODO cannot delete non-existing props and props of non-owned collections + [ + {method: 'deleteCollectionProperties', methodParams: [['testKey2']]}, + {method: 'deleteCollectionProperty', methodParams: ['testKey2']}, + ].map(testCase => + itEth(`cannot ${testCase.method}() of non-owned collections`, async ({helper}) => { + const properties = [ + {key: 'testKey1', value: 'testValue1'}, + {key: 'testKey2', value: 'testValue2'}, + ]; + const caller = await helper.eth.createAccountWithBalance(donor); + const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties}); + + const address = helper.ethAddress.fromCollectionId(collection.collectionId); + const collectionEvm = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty'); + + await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected; + expect(await collection.getProperties()).to.deep.eq(properties); + })); itEth('Can be read', async({helper}) => { const caller = helper.eth.createAccount(); -- gitstuff