@@ -211,6 +211,39 @@ it('deploy contract and interact', async () => {
211211 )
212212 }
213213
214+ // check that gas estimation reports proper error code and data for empty reverts
215+ try {
216+ let callStoreButRevert = deployed . contract . methods . storeButRevert ( 150n ) . encodeABI ( )
217+ result = await web3 . eth . estimateGas ( {
218+ from : conf . eoa . address ,
219+ to : contractAddress ,
220+ data : callStoreButRevert ,
221+ gas : 1_000_000 ,
222+ gasPrice : conf . minGasPrice
223+ } )
224+ } catch ( error ) {
225+ assert . equal ( error . innerError . code , 3 )
226+ assert . equal ( error . innerError . data , '0x' )
227+ assert . equal ( error . innerError . message , 'execution reverted' )
228+ }
229+
230+ // check that contract call reports proper error code and data for empty reverts
231+ try {
232+ let callStoreButRevert = deployed . contract . methods . storeButRevert ( 150n ) . encodeABI ( )
233+ result = await web3 . eth . call ( {
234+ from : conf . eoa . address ,
235+ to : contractAddress ,
236+ data : callStoreButRevert ,
237+ gas : 1_000_000 ,
238+ gasPrice : conf . minGasPrice
239+ } )
240+ } catch ( error ) {
241+ assert . equal ( error . innerError . code , 3 )
242+ assert . equal ( error . innerError . data , '0x' )
243+ assert . equal ( error . innerError . message , 'execution reverted' )
244+ }
245+
246+ // check that block height is properly handled by gas estimation endpoint
214247 let gasEstimate = await web3 . eth . estimateGas (
215248 {
216249 from : conf . eoa . address ,
@@ -219,7 +252,7 @@ it('deploy contract and interact', async () => {
219252 gas : 1_000_000 ,
220253 gasPrice : 0
221254 } ,
222- '0x1'
255+ '0x1' // give a block height at which the contract did not exist
223256 )
224257 assert . equal ( gasEstimate , 22026n )
225258
@@ -231,7 +264,7 @@ it('deploy contract and interact', async () => {
231264 gas : 1_000_000 ,
232265 gasPrice : 0
233266 } ,
234- 'latest'
267+ 'latest' // give a block height at which the contract did exist
235268 )
236269 assert . equal ( gasEstimate , 25050n )
237270
0 commit comments