Add E2E tests for built-in erc7562Tracer - #860
Conversation
WalkthroughAdded new test cases in tests/web3js/debug_traces_test.js to exercise the erc7562Tracer via debug_traceTransaction and debug_traceCall, validating trace payload fields, accessed storage slots (reads/writes, transient), opcode usage map, extCodeAccessInfo, contractSize, and outOfGas. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Web3.js Test
participant Node as JSON-RPC Node
participant Tracer as erc7562Tracer
Test->>Node: debug_traceTransaction(txHash, {tracer: "erc7562Tracer"})
Node->>Tracer: Execute tx with tracer hooks
Tracer-->>Node: Trace {calls, accessedSlots, usedOpcodes, ...}
Node-->>Test: Trace result
sequenceDiagram
participant Test as Web3.js Test
participant Node as JSON-RPC Node
participant Tracer as erc7562Tracer
Test->>Node: debug_traceCall(callObj, "latest", {tracer: "erc7562Tracer"})
Node->>Tracer: Simulate call with tracer hooks
Tracer-->>Node: Trace {accessedSlots, usedOpcodes, output, ...}
Node-->>Test: Trace result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/web3js/debug_traces_test.js(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (1)
tests/web3js/debug_traces_test.js (1)
186-222: Replace brittle deep‐equality with focused assertions in debug_traces_test.jsAsserting the entire
erc7562Tracerpayload—including exact opcode counts and an emptycontractSize—is prone to breakage across compiler/EVM/runtime updates. Verify only the key, stable fields and assert subsets for dynamic maps (usedOpcodes,accessedSlots) to keep tests robust without losing coverage.• File: tests/web3js/debug_traces_test.js (lines ~186–222)
- assert.deepEqual( - txTrace, - { - from: '0xfacf71692421039876a5bb4f10ef7a439d8ef61e', - gas: '0x6f9a', - gasUsed: '0x6e3f', - to: '0x99a64c993965f8d69f985b5171bc20065cc32fab', - input: '0x6babb2240000000000000000000000000000000000000000000000000000000000000064', - value: '0x0', - accessedSlots: { - reads: {}, - writes: { - '0x0000000000000000000000000000000000000000000000000000000000000000': 1 - }, - transientReads: {}, - transientWrites: {} - }, - extCodeAccessInfo: [], - usedOpcodes: { - '0x0': 1, - '0x33': 1, - '0x34': 1, - '0x35': 2, - '0x36': 2, - '0x51': 2, - '0x52': 1, - '0x55': 1, - '0x56': 10, - '0x57': 9, - '0x5b': 15, - '0xa3': 1 - }, - contractSize: {}, - outOfGas: false, - type: 'CALL' - } - ) + // Core fields + assert.equal(txTrace.from, '0xfacf71692421039876a5bb4f10ef7a439d8ef61e'); + assert.equal(txTrace.gas, '0x6f9a'); + assert.equal(txTrace.gasUsed, '0x6e3f'); + assert.equal(txTrace.to, contractAddress.toLowerCase()); + assert.equal(txTrace.input, '0x6babb2240000000000000000000000000000000000000000000000000000000000000064'); + assert.equal(txTrace.value, '0x0'); + assert.equal(txTrace.type, 'CALL'); + assert.isFalse(txTrace.outOfGas); + + // Storage accesses + const zeroSlot = '0x0000000000000000000000000000000000000000000000000000000000000000'; + assert.isObject(txTrace.accessedSlots); + assert.deepEqual(txTrace.accessedSlots.reads, {}); + assert.deepEqual(txTrace.accessedSlots.transientReads, {}); + assert.deepEqual(txTrace.accessedSlots.transientWrites, {}); + assert.equal(txTrace.accessedSlots.writes[zeroSlot], 1); + + // External code access info + assert.isArray(txTrace.extCodeAccessInfo); + assert.lengthOf(txTrace.extCodeAccessInfo, 0); + + // Opcode usage: check presence, not exact counts + assert.isObject(txTrace.usedOpcodes); + assert.containsAllKeys( + txTrace.usedOpcodes, + ['0x33','0x34','0x35','0x36','0x51','0x52','0x55','0x56','0x57','0x5b'] + ); + assert.isAtLeast(txTrace.usedOpcodes['0x55'], 1); + + // Contract size should exist (may be dynamic) + assert.isObject(txTrace.contractSize);
Work Towards: #840
Description
Adds some E2E tests to verify the functionality of the new
erc7562Tracertracer.For contributor use:
masterbranchFiles changedin the Github PR explorerSummary by CodeRabbit