Skip to content

test(rpc): cover BatchSizeLimitMiddleware with max_entries=0 - #154

Closed
Kewe63 wants to merge 1 commit into
circlefin:mainfrom
Kewe63:test/batch-size-limit-edge-cases
Closed

Kewe63 wants to merge 1 commit into
circlefin:mainfrom
Kewe63:test/batch-size-limit-edge-cases

Conversation

@Kewe63

@Kewe63 Kewe63 commented Jun 15, 2026

Copy link
Copy Markdown

Summary

BatchSizeLimitMiddleware accepts a max_entries: usize and rejects any batch whose length exceeds it. The CLI value parser parse_max_batch_entries rejects 0 with must be >= 1, so the runtime cap is always at least 1. However, the in-process BatchSizeLimitMiddleware::new constructor has no such guard — callers can intentionally build a "no batches allowed" layer with max_entries = 0, and the middleware must behave sensibly in that case.

This corner case had no test coverage.


Fix

Added a focused test locking in the documented behavior for max_entries = 0:

  • Any non-empty batch is rejected with BATCH_TOO_LARGE_ERROR_CODE, and the error message names the offending size and limit.
  • Empty batches are deliberately not asserted on: MockRpcService rejects empty batches with a different error code (-32600 "Invalid request"), and pinning the middleware's response shape on top of that quirk would lock in the wrong contract. The empty-batch case is left to the JSON-RPC layer below the middleware.

Changes

File: crates/arc-evm-node/src/ (batch size limit tests)

  • Added batch_size_limit_max_entries_zero test covering the max_entries = 0 case with non-empty batch inputs.

How to Test

# Batch size limit tests
cargo test -p arc-evm-node --lib batch_size_limit
# ✅ 7 passed, 0 failed

# Format & lint
cargo fmt --check -p arc-evm-node
cargo clippy -p arc-evm-node --tests -- -D warnings
# ✅ Both clean

Risk & Impact

None. Test-only addition — no production code modified. Locks in correct middleware behavior for an untested constructor edge case.

Type: 🧪 Test coverage

The middleware's `max_entries = 0` corner case (allowed in-process
because `BatchSizeLimitMiddleware::new` has no guard, even though
the CLI value parser `parse_max_batch_entries` rejects 0) was
untested. Add a focused test that locks in the documented behaviour:
any non-empty batch is rejected with `BATCH_TOO_LARGE_ERROR_CODE`,
and the error message names the offending size and limit.

An empty-batch pass-through test was considered and dropped: the
`MockRpcService` itself rejects empty batches with a different
error code (-32600 'Invalid request'), and asserting on the
final response shape would lock in that quirk rather than the
middleware's contract. The empty-batch case is left to the
JSON-RPC layer below the middleware.
@ZhiyuCircle

Copy link
Copy Markdown
Contributor

Hi @Kewe63,

Thank you for your interest in contributing to Arc Node, and apologies for the delay in getting back to this PR.

We're closing out the pull request backlog that predates our current contribution policy. This PR is being closed because it does not reference a GitHub issue. All PRs must reference an existing issue using the format Closes: #XXX, and the author must be assigned to that issue before the PR is opened.

This is not a judgement on the change itself. If you'd still like to land it:

  1. Open an issue describing the problem, or find the existing one
  2. Comment on the issue requesting assignment, and wait for maintainer approval
  3. Open a fresh PR once you have been assigned

Please see CONTRIBUTING.md for details. Thanks again for taking the time to contribute.

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

Labels

EL Component: EL need-triage test Test-only additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants