test(cli/mev): add integration tests for MEV test command#329
test(cli/mev): add integration tests for MEV test command#329varex83agent wants to merge 22 commits intomainfrom
Conversation
- Follow the `test validator` approach (enum + impl block) - Simplify error handling for timeouts
- Test is already cancelled by caller appropriately
- Workaround for false positive
- Use tokio::time::Instant instead of std::time::Instant in async code - Replace CliError::Other string literals with typed variants TimeoutInterrupted and TestCaseNotSupported - Remove TestResultError from imports; use CliError::TimeoutInterrupted directly - Simplify latest_beacon_block and fetch_proposers_for_epoch to use ? operator, leveraging existing From impls on CliError - Simplify get_block_header error conversions with .map_err(MevError::from) and .map_err(|e| MevError::Cli(e.into())) Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
RUSTSEC-2026-0097: rand 0.8.x unsoundness (transitive dep) RUSTSEC-2026-0098: rustls-webpki URI name constraint bypass (transitive dep) Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
These features are absent from Charon v1.7.1: - Remove x-timeout-ms CLI flag and x_timeout_ms field from TestMevArgs - Remove X-Timeout-Ms and Date-Milliseconds headers from get_block_header - Remove credential parsing (parse_endpoint_credentials / apply_basic_auth) from mev_ping_test, latest_beacon_block, fetch_proposers_for_epoch, and get_block_header - Replace x_timeout_ms-based thresholds in mev_create_block_test with fixed 500ms/800ms constants matching Go reference thresholds Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
Resolve conflicts: - deny.toml: adopt main's detailed reason comment for RUSTSEC-2026-0097, keep RUSTSEC-2026-0098 - crates/cli/Cargo.toml: add chrono from main - crates/cli/src/commands/test/mod.rs: accept main's refactor (helpers/constants modules) - crates/cli/src/commands/test/mev.rs: update imports for helpers/constants split, use SLOTS_IN_EPOCH.get() for NonZero<u64> Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
Port tests from testmev_internal_test.go covering: - default scenario: healthy MEV node returns Ping OK, PingMeasure Good, CreateBlock Skip - connection refused: Ping and PingMeasure fail with error, CreateBlock skips - timeout: very short timeout causes Fail verdicts for network tests - quiet mode: no stdout output when quiet=true - unsupported test case: returns "test case not supported" error - custom test cases filter: only specified tests are run - write to file: output_json path produces valid JSON with mev key Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
rustls-webpki wildcard name constraint bypass — transitive dep, cannot upgrade immediately. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
There was a problem hiding this comment.
This can silently fail, would be better to return an error.
There was a problem hiding this comment.
those two as well, why not return an error?
mskrzypkows
left a comment
There was a problem hiding this comment.
LGTM, I would just change some unwraps to returning errors in case this code would be used in different context.
|
@claude merge main and fix comments |
|
Claude finished @varex83's task in 4m 36s —— View job Tasks
What was doneReplaced all six
Commit: |
Replace silent unwrap_or fallbacks on checked arithmetic and numeric conversions with explicit error returns, so callers observe failures instead of silently continuing with sentinel values. Co-authored-by: Bohdan Ohorodnii <varex83@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
- Adopt CancellationToken by-value signature from main - Keep proper error propagation from PR (replace unwrap_or fallbacks) - Update test call sites to CancellationToken::new() by value - Adopt main's test naming convention Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
Move the local MevError out of mev.rs into the public MevTestError type in error.rs, and add CliError::MevTest(#[from] MevTestError). The Cli wrapper variant is dropped — get_block_header now returns Result<_, CliError> directly, letting ? propagate reqwest/serde errors and using MevTestError::StatusCodeNot200 for the non-200 retry path. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
…r variants Add 13 new MevTestError variants covering every CliError::Other site in mev.rs: HttpStatus, BeaconNodeEndpointRequired, BeaconNodeEndpointNotAllowed, ParseTimestamp, TimestampOverflow, NextBlockTimestampOverflow, ParseSlot, SlotsInEpochConversion, EpochCalculationOverflow, ElapsedNanosConversion, BlockCountConversion, SlotNotFound, PayloadMarshal, UnsupportedVersionOrMissingHeader. Remove the now-dead http_status_error helper. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
|
@claude review |
|
Claude finished @varex83's task in 3m 3s —— View job Code ReviewTasks
Overall the PR is solid — good test coverage for the non-load-test paths, clean Bugs / Issues1.
|
- test_mev_timeout: use MockServer with 500ms delay and 10ms timeout to actually exercise the token.cancelled() / TimeoutInterrupted path - Replace hardcoded ports 19950-19960 with refused_addr() helper that binds :0 and drops the listener, giving OS-assigned ports that are guaranteed available - test_mev_default_scenario: assert PingMeasure is Good|Poor instead of exact Good to avoid latency-sensitive flakiness on loaded CI runners - Replace infallible u32→usize and SLOT_TIME→u64 try_from/unwrap_or with direct as casts - deny.toml: add reason fields to RUSTSEC-2026-0098 and RUSTSEC-2026-0099 Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
|
@claude re-review please, check if all issues were addressed |
Re-review: Checking if all issues were addressed
Tasks
|
- Revert SLOT_TIME as-cast to try_from/unwrap_or to satisfy clippy::cast_possible_truncation - Rename test functions to drop redundant `test_` prefix (clippy::redundant_test_prefix) Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>

Summary
Follow-up to #300. Adds the integration tests missing from the initial MEV test implementation, as noted in the review thread.
Ping OK,PingMeasure Good,CreateBlock SkipPing Fail,PingMeasure Fail,CreateBlock Skipwith error messages--quietproduces no stdout output"test case not supported"error--test-cases=Pingruns onlyPingper endpoint--output-jsonproduces valid JSON withmevkeyTests ported from
testmev_internal_test.go. Thedefault load scenarioand flag-parsing tests are deferred to a further follow-up since they require a live beacon node or deeper CLI wiring.Test plan
cargo test --package pluto-cli --bin pluto -- commands::test::mev::testspasses (9/9)cargo clippycleancargo +nightly fmtcleancargo deny checkclean🤖 Generated with Claude Code