Skip to content

Commit 5e926de

Browse files
committed
Add test cases for revert returned data on debug_traceCall
1 parent 6192a08 commit 5e926de

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/web3js/debug_traces_test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,4 +859,50 @@ it('should retrieve call traces', async () => {
859859
)
860860
assert.equal(updateTrace.value, '0x0')
861861
assert.equal(updateTrace.type, 'CALL')
862+
863+
// assert return value of empty revert data for default struct logger tracer
864+
let callStoreButRevert = deployed.contract.methods.storeButRevert(150n).encodeABI()
865+
traceCall = {
866+
from: conf.eoa.address,
867+
to: contractAddress,
868+
data: callStoreButRevert,
869+
value: '0x0',
870+
gasPrice: web3.utils.toHex(conf.minGasPrice),
871+
gas: '0x95ab'
872+
}
873+
response = await helpers.callRPCMethod(
874+
'debug_traceCall',
875+
[traceCall, 'latest', { tracer: null }]
876+
)
877+
assert.equal(response.status, 200)
878+
assert.isDefined(response.body)
879+
880+
let traceResult = response.body.result
881+
assert.equal(traceResult.gas, 26677)
882+
assert.equal(traceResult.failed, true)
883+
assert.equal(traceResult.returnValue, '0x')
884+
assert.lengthOf(traceResult.structLogs, 138)
885+
886+
// assert return value of non-empty revert data for default struct logger tracer
887+
let callCustomError = deployed.contract.methods.customError().encodeABI()
888+
traceCall = {
889+
from: conf.eoa.address,
890+
to: contractAddress,
891+
data: callCustomError,
892+
value: '0x0',
893+
gasPrice: web3.utils.toHex(conf.minGasPrice),
894+
gas: '0x95ab'
895+
}
896+
response = await helpers.callRPCMethod(
897+
'debug_traceCall',
898+
[traceCall, 'latest', { tracer: null }]
899+
)
900+
assert.equal(response.status, 200)
901+
assert.isDefined(response.body)
902+
903+
traceResult = response.body.result
904+
assert.equal(traceResult.gas, 21786)
905+
assert.equal(traceResult.failed, true)
906+
assert.equal(traceResult.returnValue, '0x9195785a00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001056616c756520697320746f6f206c6f7700000000000000000000000000000000')
907+
assert.lengthOf(traceResult.structLogs, 210)
862908
})

tests/web3js/eth_deploy_contract_and_interact_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ it('deploy contract and interact', async () => {
221221
gas: 1_000_000,
222222
gasPrice: conf.minGasPrice
223223
})
224+
assert.fail('expected eth_estimateGas to revert with empty revert data')
224225
} catch (error) {
225226
assert.equal(error.innerError.code, 3)
226227
assert.equal(error.innerError.data, '0x')
@@ -237,6 +238,7 @@ it('deploy contract and interact', async () => {
237238
gas: 1_000_000,
238239
gasPrice: conf.minGasPrice
239240
})
241+
assert.fail('expected eth_call to revert with empty revert data')
240242
} catch (error) {
241243
assert.equal(error.innerError.code, 3)
242244
assert.equal(error.innerError.data, '0x')

0 commit comments

Comments
 (0)