git.delta.rocks / unique-network / refs/commits / 9764f292137d

difftreelog

setCollectionProperties - multiple properties test

Max Andreev2022-12-06parent: #fc6fcf2.patch.diff
in: master
+ combine with setCollectionProperty

1 file changed

modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
31 });31 });
32 });32 });
3333
34 // Soft-deprecated: setCollectionProperty
35 [{method: 'setCollectionProperties', methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},
36 {method: 'setCollectionProperty', methodParams: ['testKey', Buffer.from('testValue')], expectedProps: [{key: 'testKey', value: 'testValue'}]},
37 ].map(testCase =>
34 itEth('Can be set', async({helper}) => {38 itEth(`Collection properties can be set: ${testCase.method}`, async({helper}) => {
35 const caller = await helper.eth.createAccountWithBalance(donor);39 const caller = await helper.eth.createAccountWithBalance(donor);
36 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});40 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
37 await collection.addAdmin(alice, {Ethereum: caller});41 await collection.addAdmin(alice, {Ethereum: caller});
3842
39 const address = helper.ethAddress.fromCollectionId(collection.collectionId);43 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
40 const contract = helper.ethNativeContract.collection(address, 'nft', caller);44 const contract = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'setCollectionProperty');
4145
42 await contract.methods.setCollectionProperties([{key: 'testKey', value: Buffer.from('testValue')}]).send({from: caller});46 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});
4347
44 const raw = (await collection.getData())?.raw;48 const raw = (await collection.getData())?.raw;
45
46 expect(raw.properties[0].value).to.equal('testValue');49 expect(raw.properties).to.deep.equal(testCase.expectedProps);
47 });50 }));
51
4852
49 itEth('Can be deleted', async({helper}) => {53 itEth('Can be deleted', async({helper}) => {
73 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));77 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));
74 });78 });
75
76 // Soft-deprecated
77 itEth('Collection property can be set', async({helper}) => {
78 const caller = await helper.eth.createAccountWithBalance(donor);
79 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});
80 await collection.addAdmin(alice, {Ethereum: caller});
81
82 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
83 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);
84
85 await contract.methods.setCollectionProperty('testKey', Buffer.from('testValue')).send();
86
87 const raw = (await collection.getData())?.raw;
88
89 expect(raw.properties[0].value).to.equal('testValue');
90 });
9179
92 // Soft-deprecated80 // Soft-deprecated
93 itEth('Collection property can be deleted', async({helper}) => {81 itEth('Collection property can be deleted', async({helper}) => {