Skip to content

Conversation

rekmarks
Copy link
Member

Explanation

The block-ref-rewrite middleware lacked a dedicated test suite, making it difficult to verify its behavior and prevent regressions. This PR introduces a comprehensive test suite for createBlockRefRewriteMiddleware.

The new tests cover:

  • Error handling for missing blockTracker dependency.
  • Scenarios where block reference rewriting should be skipped (e.g., methods without block reference parameters, non-"latest" block references).
  • Core functionality, ensuring "latest" block references are correctly rewritten to actual block numbers for various RPC methods (eth_getBalance, eth_getStorageAt, eth_getBlockByNumber).
  • Edge cases, such as handling omitted block references (which should default to "latest") and non-array parameters.
  • Verification that other request properties remain unchanged during the rewrite process.

The tests utilize JsonRpcEngine and a mock PollingBlockTracker to simulate realistic usage and assert the middleware's impact on RPC requests.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Oct 23, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants