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

difftreelog

Add setCollectionProperties negative test

Max Andreev2022-12-06parent: #4cd5a26.patch.diff
in: master

1 file changed

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
49 expect(raw.properties).to.deep.equal(testCase.expectedProps);50 expect(raw.properties).to.deep.equal(testCase.expectedProps);
50 }));51 }));
52
53 itEth('Cannot set invalid properties', async({helper}) => {
54 const caller = await helper.eth.createAccountWithBalance(donor);
55 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
56 await collection.addAdmin(alice, {Ethereum: caller});
57
58 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
59 const contract = helper.ethNativeContract.collection(address, 'nft', caller);
60
61 await expect(contract.methods.setCollectionProperties([{key: '', value: Buffer.from('val1')}]).send({from: caller})).to.be.rejected;
62 await expect(contract.methods.setCollectionProperties([{key: 'déjà vu', value: Buffer.from('hmm...')}]).send({from: caller})).to.be.rejected;
63 await expect(contract.methods.setCollectionProperties([{key: 'a'.repeat(257), value: Buffer.from('val3')}]).send({from: caller})).to.be.rejected;
64 // TODO add more expects
65 const raw = (await collection.getData())?.raw;
66 expect(raw.properties).to.deep.equal([]);
67 });
5168
5269
53 // Soft-deprecated: deleteCollectionProperty70 // Soft-deprecated: deleteCollectionProperty
75 expect(raw.properties).to.deep.equal(testCase.expectedProps);93 expect(raw.properties).to.deep.equal(testCase.expectedProps);
76 }));94 }));
95
96 // TODO cannot delete non-existing props and props of non-owned collections
7797
78 itEth('Can be read', async({helper}) => {98 itEth('Can be read', async({helper}) => {
79 const caller = helper.eth.createAccount();99 const caller = helper.eth.createAccount();