-
Notifications
You must be signed in to change notification settings - Fork 12
Update eth_estimateGas to correctly handle execution reverts
#303
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,4 +173,40 @@ it('deploy contract and interact', async() => { | |
| ) | ||
| } | ||
|
|
||
| // check that revert reason for custom error is correctly returned for gas estimation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets create maybe gast estimation test separately, because it feels to me we will have multiple tests with weird cases
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. It has become quite large, I must admit. I'll leave it for another PR though. |
||
| try { | ||
| let callCustomError = deployed.contract.methods.customError().encodeABI() | ||
| result = await web3.eth.estimateGas({ | ||
| from: conf.eoa.address, | ||
| to: contractAddress, | ||
| data: callCustomError, | ||
| gas: 1_000_000, | ||
| gasPrice: 0 | ||
| }) | ||
| } catch (error) { | ||
| assert.equal(error.innerError.message, 'execution reverted') | ||
| assert.equal( | ||
| error.innerError.data, | ||
| '0x9195785a00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001056616c756520697320746f6f206c6f7700000000000000000000000000000000' | ||
| ) | ||
| } | ||
|
|
||
| // check that assertion error is correctly returned for gas estimation | ||
| try { | ||
| let callAssertError = deployed.contract.methods.assertError().encodeABI() | ||
| result = await web3.eth.estimateGas({ | ||
| from: conf.eoa.address, | ||
| to: contractAddress, | ||
| data: callAssertError, | ||
| gas: 1_000_000, | ||
| gasPrice: 0 | ||
| }) | ||
| } catch (error) { | ||
| assert.equal(error.innerError.message, 'execution reverted: Assert Error Message') | ||
| assert.equal( | ||
| error.innerError.data, | ||
| '0x08c379a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000014417373657274204572726f72204d657373616765000000000000000000000000' | ||
| ) | ||
| } | ||
|
|
||
| }).timeout(10*1000) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we removed this because we handle it in the EVM core now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly, this is done by
EVM.dryRunnow.