test(cli/mev): add integration tests for MEV test command#329
Open
varex83agent wants to merge 16 commits intomainfrom
Open
test(cli/mev): add integration tests for MEV test command#329varex83agent wants to merge 16 commits intomainfrom
varex83agent wants to merge 16 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>
mskrzypkows
reviewed
Apr 23, 2026
|
|
||
| let latest_block_ts = std::time::UNIX_EPOCH | ||
| .checked_add(Duration::from_secs(latest_block_ts_unix.unsigned_abs())) | ||
| .unwrap_or(std::time::UNIX_EPOCH); |
Contributor
There was a problem hiding this comment.
This can silently fail, would be better to return an error.
mskrzypkows
reviewed
Apr 23, 2026
| .unwrap_or(std::time::UNIX_EPOCH); | ||
| let next_block_ts = latest_block_ts | ||
| .checked_add(SLOT_TIME) | ||
| .unwrap_or(latest_block_ts); |
mskrzypkows
reviewed
Apr 23, 2026
|
|
||
| let mut next_slot = latest_slot.saturating_add(1); | ||
| let slots_in_epoch_i64 = i64::try_from(SLOTS_IN_EPOCH.get()).unwrap_or(i64::MAX); | ||
| let epoch = next_slot.checked_div(slots_in_epoch_i64).unwrap_or(0); |
Contributor
There was a problem hiding this comment.
those two as well, why not return an error?
mskrzypkows
reviewed
Apr 23, 2026
| } | ||
|
|
||
| let elapsed = start_iteration.elapsed(); | ||
| let elapsed_nanos = u64::try_from(elapsed.as_nanos()).unwrap_or(u64::MAX); |
mskrzypkows
reviewed
Apr 23, 2026
| } | ||
|
|
||
| let total_rtt: Duration = all_blocks_rtt.iter().sum(); | ||
| let count = u32::try_from(all_blocks_rtt.len().max(1)).unwrap_or(u32::MAX); |
mskrzypkows
reviewed
Apr 23, 2026
| loop { | ||
| let start_iteration = Instant::now(); | ||
| let slots_in_epoch_i64 = i64::try_from(SLOTS_IN_EPOCH.get()).unwrap_or(i64::MAX); | ||
| let epoch = next_slot.checked_div(slots_in_epoch_i64).unwrap_or(0); |
mskrzypkows
reviewed
Apr 23, 2026
Contributor
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.
mskrzypkows
approved these changes
Apr 23, 2026
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
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