test(rpc): cover BatchSizeLimitMiddleware with max_entries=0#154
Open
Kewe63 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BatchSizeLimitMiddlewareaccepts amax_entries: usizeand rejects any batch whose length exceeds it. The CLI value parserparse_max_batch_entriesrejects0withmust be >= 1, so the runtime cap is always at least 1. However, the in-processBatchSizeLimitMiddleware::newconstructor has no such guard — callers can intentionally build a "no batches allowed" layer withmax_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:BATCH_TOO_LARGE_ERROR_CODE, and the error message names the offending size and limit.MockRpcServicerejects 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)batch_size_limit_max_entries_zerotest covering themax_entries = 0case with non-empty batch inputs.How to Test
Risk & Impact
None. Test-only addition — no production code modified. Locks in correct middleware behavior for an untested constructor edge case.
Type: 🧪 Test coverage