difftreelog
setCollectionProperties - multiple properties test
in: master
+ combine with setCollectionProperty
1 file changed
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth31 });31 });32 });32 });333334 // Soft-deprecated: setCollectionProperty35 [{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});384239 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');414542 await contract.methods.setCollectionProperties([{key: 'testKey', value: Buffer.from('testValue')}]).send({from: caller});46 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});434744 const raw = (await collection.getData())?.raw;48 const raw = (await collection.getData())?.raw;4546 expect(raw.properties[0].value).to.equal('testValue');49 expect(raw.properties).to.deep.equal(testCase.expectedProps);47 });50 }));51485249 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 });7576 // Soft-deprecated77 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});8182 const address = helper.ethAddress.fromCollectionId(collection.collectionId);83 const contract = helper.ethNativeContract.collection(address, 'nft', caller, true);8485 await contract.methods.setCollectionProperty('testKey', Buffer.from('testValue')).send();8687 const raw = (await collection.getData())?.raw;8889 expect(raw.properties[0].value).to.equal('testValue');90 });917992 // Soft-deprecated80 // Soft-deprecated93 itEth('Collection property can be deleted', async({helper}) => {81 itEth('Collection property can be deleted', async({helper}) => {