hyperledger / caliper-benchmarks

Sample benchmark files for Hyperledger Caliper https://wiki.hyperledger.org/display/caliper
https://hyperledger.github.io/caliper-benchmarks/
Apache License 2.0
113 stars 120 forks source link

Caliper Benchmark Ethereum: Payable functions #81

Open canarseven opened 4 years ago

canarseven commented 4 years ago

One of my Ethereum smart contract functions is of type payable. Thus, I need to send a certain amount of ether to the function so it executes its logic. I could not find such a field provided by your Blockchain call function blockchain.invokeSmartContract(), I also looked at caliper/packages/caliper-ethereum/lib/ethereum.js trying to find a field or function to specify but still have no clue.

Appreciate any hint or idea on what I could do to test my payable function through Caliper.

aklenik commented 4 years ago

@benjamincburns Can you help with this question/request?

canarseven commented 4 years ago

Just to reiterate over my question, because maybe it was too ambiguous:

For example: I have a function of this format in my smart contract: function sendMeEther() payable public { contractValue += msg.value }

And would like to send ether by setting the value field in my transaction call to this function. Otherwise, my function will not compute correctly. With web3js I would do it like this e.g:

web3.eth.sendTransaction({ from: '0x.....', to: '0x....', value: myValue.asHex() })

Thus, how can I access this through the Caliper Blockchain class inside my benchmark js? Suggestions on how to access it not through the Blockchain class but through other ways, is also appreciated! :)

fbalwy commented 3 years ago

Any answer to this question yet?

nachikettapas commented 3 years ago

Following the question.

nachikettapas commented 3 years ago

Following the question.

If anyone is still looking for the solution, I created a PR #1122 and #1124 for this. For usage, check caliper documentation for version vNext. Also, you can have a look at integration tests about how to use value parameter.

https://github.com/hyperledger/caliper/blob/master/packages/caliper-tests-integration/ethereum_tests/open.js