Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/web3js/debug_traces_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,4 +859,50 @@ it('should retrieve call traces', async () => {
)
assert.equal(updateTrace.value, '0x0')
assert.equal(updateTrace.type, 'CALL')

// assert return value of empty revert data for default struct logger tracer
let callStoreButRevert = deployed.contract.methods.storeButRevert(150n).encodeABI()
traceCall = {
from: conf.eoa.address,
to: contractAddress,
data: callStoreButRevert,
value: '0x0',
gasPrice: web3.utils.toHex(conf.minGasPrice),
gas: '0x95ab'
}
response = await helpers.callRPCMethod(
'debug_traceCall',
[traceCall, 'latest', { tracer: null }]
)
assert.equal(response.status, 200)
assert.isDefined(response.body)

let traceResult = response.body.result
assert.equal(traceResult.gas, 26677)
assert.equal(traceResult.failed, true)
assert.equal(traceResult.returnValue, '0x')
assert.lengthOf(traceResult.structLogs, 138)

// assert return value of non-empty revert data for default struct logger tracer
let callCustomError = deployed.contract.methods.customError().encodeABI()
traceCall = {
from: conf.eoa.address,
to: contractAddress,
data: callCustomError,
value: '0x0',
gasPrice: web3.utils.toHex(conf.minGasPrice),
gas: '0x95ab'
}
response = await helpers.callRPCMethod(
'debug_traceCall',
[traceCall, 'latest', { tracer: null }]
)
assert.equal(response.status, 200)
assert.isDefined(response.body)

traceResult = response.body.result
assert.equal(traceResult.gas, 21786)
assert.equal(traceResult.failed, true)
assert.equal(traceResult.returnValue, '0x9195785a00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001056616c756520697320746f6f206c6f7700000000000000000000000000000000')
assert.lengthOf(traceResult.structLogs, 210)
})
39 changes: 37 additions & 2 deletions tests/web3js/eth_deploy_contract_and_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,41 @@ it('deploy contract and interact', async () => {
)
}

// check that gas estimation reports proper error code and data for empty reverts
try {
let callStoreButRevert = deployed.contract.methods.storeButRevert(150n).encodeABI()
result = await web3.eth.estimateGas({
from: conf.eoa.address,
to: contractAddress,
data: callStoreButRevert,
gas: 1_000_000,
gasPrice: conf.minGasPrice
})
assert.fail('expected eth_estimateGas to revert with empty revert data')
} catch (error) {
assert.equal(error.innerError.code, 3)
assert.equal(error.innerError.data, '0x')
assert.equal(error.innerError.message, 'execution reverted')
}

// check that contract call reports proper error code and data for empty reverts
try {
let callStoreButRevert = deployed.contract.methods.storeButRevert(150n).encodeABI()
result = await web3.eth.call({
from: conf.eoa.address,
to: contractAddress,
data: callStoreButRevert,
gas: 1_000_000,
gasPrice: conf.minGasPrice
})
assert.fail('expected eth_call to revert with empty revert data')
} catch (error) {
assert.equal(error.innerError.code, 3)
assert.equal(error.innerError.data, '0x')
assert.equal(error.innerError.message, 'execution reverted')
}

// check that block height is properly handled by gas estimation endpoint
let gasEstimate = await web3.eth.estimateGas(
{
from: conf.eoa.address,
Expand All @@ -219,7 +254,7 @@ it('deploy contract and interact', async () => {
gas: 1_000_000,
gasPrice: 0
},
'0x1'
'0x1' // give a block height at which the contract did not exist
)
assert.equal(gasEstimate, 22026n)

Expand All @@ -231,7 +266,7 @@ it('deploy contract and interact', async () => {
gas: 1_000_000,
gasPrice: 0
},
'latest'
'latest' // give a block height at which the contract did exist
)
assert.equal(gasEstimate, 25050n)

Expand Down