git.delta.rocks / unique-network / refs/commits / 8a193aa1d0a5

difftreelog

cannot delete prop of non-owned collections

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

1 file changed

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
72 {method: 'deleteCollectionProperties', methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},72 {method: 'deleteCollectionProperties', methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},
73 {method: 'deleteCollectionProperty', methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]}, 73 {method: 'deleteCollectionProperty', methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]},
74 ].map(testCase => 74 ].map(testCase =>
75 itEth(`Collection properties can be deleted: ${testCase.method}`, async({helper}) => {75 itEth(`Collection properties can be deleted: ${testCase.method}()`, async({helper}) => {
76 const properties = [76 const properties = [
77 {key: 'testKey1', value: 'testValue1'},77 {key: 'testKey1', value: 'testValue1'},
78 {key: 'testKey2', value: 'testValue2'},78 {key: 'testKey2', value: 'testValue2'},
93 expect(raw.properties).to.deep.equal(testCase.expectedProps);93 expect(raw.properties).to.deep.equal(testCase.expectedProps);
94 }));94 }));
95 95
96 // TODO cannot delete non-existing props and props of non-owned collections96
97 [
98 {method: 'deleteCollectionProperties', methodParams: [['testKey2']]},
99 {method: 'deleteCollectionProperty', methodParams: ['testKey2']},
100 ].map(testCase =>
101 itEth(`cannot ${testCase.method}() of non-owned collections`, async ({helper}) => {
102 const properties = [
103 {key: 'testKey1', value: 'testValue1'},
104 {key: 'testKey2', value: 'testValue2'},
105 ];
106 const caller = await helper.eth.createAccountWithBalance(donor);
107 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});
108
109 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
110 const collectionEvm = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');
111
112 await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected;
113 expect(await collection.getProperties()).to.deep.eq(properties);
114 }));
97115
98 itEth('Can be read', async({helper}) => {116 itEth('Can be read', async({helper}) => {
99 const caller = helper.eth.createAccount();117 const caller = helper.eth.createAccount();