Skip to content

Add E2E tests for built-in erc7562Tracer - #860

Merged
m-Peter merged 1 commit into
mainfrom
mpeter/e2e-tests-erc7562Tracer
Aug 15, 2025
Merged

Add E2E tests for built-in erc7562Tracer#860
m-Peter merged 1 commit into
mainfrom
mpeter/e2e-tests-erc7562Tracer

Conversation

@m-Peter

@m-Peter m-Peter commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator

Work Towards: #840

Description

Adds some E2E tests to verify the functionality of the new erc7562Tracer tracer.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • Tests
    • Added comprehensive tests for the new erc7562 tracer across transaction and call tracing.
    • Validates core trace details (call metadata, accessed slots, opcode usage, and gas/out-of-gas behavior) to ensure accuracy.
    • Ensures compatibility alongside existing tracers and strengthens overall trace reliability.

@coderabbitai

coderabbitai Bot commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Added 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

Cohort / File(s) Summary
Tracer tests update
tests/web3js/debug_traces_test.js
Introduces erc7562Tracer tests for debug_traceTransaction and debug_traceCall, asserting trace structure (from/to/input/value/type), accessedSlots (reads/writes/transient), extCodeAccessInfo, usedOpcodes map, contractSize, outOfGas, and specific payload/slot expectations.

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
Loading
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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • janezpodhostnik
  • zhangchiqing
  • peterargue

Poem

A hop, a skip, I trace the call,
Slots I sniff, both big and small.
Opcodes counted, neat and clear,
No gas lost—still plenty here.
With twitching nose and fluffy flair,
I map the paths through EVM air.
Thump-thump! The tracer’s there.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mpeter/e2e-tests-erc7562Tracer

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96eff65 and e69970a.

📒 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.js

Asserting the entire erc7562Tracer payload—including exact opcode counts and an empty contractSize—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);

Comment thread tests/web3js/debug_traces_test.js
@m-Peter
m-Peter merged commit 4c69cf8 into main Aug 15, 2025
2 checks passed
@m-Peter
m-Peter deleted the mpeter/e2e-tests-erc7562Tracer branch August 15, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants