Skip to content

Conversation

@niran
Copy link
Contributor

@niran niran commented Jan 11, 2026

Summary

  • Refactor metering tests to use shared test infrastructure from base-reth-test-utils
  • Move all tests inline following the base-bundles pattern with #[cfg(test)] modules
  • Add MeteringTestContext for unit tests and metering_launcher for RPC module injection
  • Remove tests/ directory - all 18 tests now run as unit tests

Supersedes #338.

Changes

Test Infrastructure:

  • Add signer_b256() method to Account in test-utils for transaction signing
  • Rename to MeteringTestContext - bundles provider, header, and chain_spec for metering function tests
  • Create metering_launcher - node launcher that injects the metering RPC module

Test Organization (base-bundles pattern):

  • Use #[cfg(any(test, feature = "test-utils"))] for test_utils module
  • List test dependencies in both [features] (optional) and [dev-dependencies]
  • Move tests inline to source files with #[cfg(test)] modules
  • Remove separate tests/ directory entirely

Files:

  • src/meter.rs - 3 tests for meter_bundle()
  • src/block.rs - 6 tests for meter_block()
  • src/rpc.rs - 9 tests for RPC endpoints

Test plan

  • All 18 metering tests pass: cargo test -p base-reth-metering
  • Unit tests run separately: cargo test -p base-reth-metering --lib
  • test-utils feature works: cargo check -p base-reth-metering --features test-utils

niran added 4 commits January 10, 2026 20:14
Replace custom NodeContext and setup_node() with TestHarness::with_launcher()
from base-reth-test-utils. This eliminates duplicated node setup code and
uses the shared test infrastructure.

Changes:
- Add metering_launcher to test_utils module for RPC module injection
- Add signer_b256() helper to Account for TransactionBuilder compatibility
- Refactor meter_rpc.rs to use TestHarness, ALICE, BOB from test-utils
Introduce MeteringTestContext to bundle the provider, header, and chain
spec needed by meter_bundle() and meter_block() functions. This replaces
the duplicated setup code in meter.rs and meter_block.rs.

The context is metering-specific because it matches the function
signatures of the metering API and provides the exact arguments needed
for testing metering logic without a full node.
…tern

Move meter_bundle and meter_block tests from tests/ directory to inline
#[cfg(test)] modules in their respective source files. This follows the
base-bundles pattern where unit tests live alongside the code they test.

- Use #[cfg(any(test, feature = "test-utils"))] for test_utils module
- Add test dependencies as dev-deps for #[cfg(test)] code access
- Keep meter_rpc.rs as integration test (requires running node)
- Keep self-reference dev-dep for integration test feature access
Move all RPC tests from tests/meter_rpc.rs to inline #[cfg(test)] module
in src/rpc.rs. With all tests now inline, the tests/ directory and
self-reference dev-dependency are no longer needed.

All 18 metering tests now run as unit tests in a single test binary.
@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 11, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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.

3 participants