Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with require() #11

Open
hilmarx opened this issue Jul 15, 2019 · 5 comments
Open

Compatibility with require() #11

hilmarx opened this issue Jul 15, 2019 · 5 comments

Comments

@hilmarx
Copy link

hilmarx commented Jul 15, 2019

Firstly thanks for putting the resources of live testing using estimateGas() together.

My question: Is there a way to retrieve the current blocks gasLimit in case of encountering a revert() in the gas estimation if the contract to be tested only uses revert() instead of assert()? I tried to make it work locally in truffle with web3 1.0, but this only seems to work when the deployed contract actually uses assert(), which is rarely the case these days due to the gas refund property of require(). Based on my current understanding one would have to redeploy the contracts to be tested and use assert() instead of require().

Thanks for your help!

@MoMannn
Copy link
Collaborator

MoMannn commented Jul 15, 2019

When reverts happens you will get a: gas required exceeds allowance or always failing transaction error. At least from geth. If not and you can get gasLimit information from the latest block by calling: eth_getblockbyhash or eth_getblockbynumber.

@hilmarx
Copy link
Author

hilmarx commented Jul 15, 2019

Thanks. I haven't tried this directly with Geth, but it seems that the web3.js library with which I am currently trying this out won't return the gas required ... error, but only the consumed gas up until the revert() got triggered, hence not really being helpful in determining whether the tx will fail or not.

@hilmarx
Copy link
Author

hilmarx commented Jul 15, 2019

Solved, was only an issue with ganache, works with geth + web3.

@fulldecent
Copy link
Owner

Thanks for writing in, please share a link if you have any code samples or your own project.

@hilmarx
Copy link
Author

hilmarx commented Jul 16, 2019

@fulldecent will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants