Skip to content

feat(cli): beacon CLI tests#294

Merged
mskrzypkows merged 47 commits intomainfrom
beacon_cli_tests
Apr 1, 2026
Merged

feat(cli): beacon CLI tests#294
mskrzypkows merged 47 commits intomainfrom
beacon_cli_tests

Conversation

@mskrzypkows
Copy link
Copy Markdown
Contributor

CLI beacon tests ported from Charon, fixes #233

Copilot AI review requested due to automatic review settings March 23, 2026 10:41
@mskrzypkows mskrzypkows requested review from Copilot, emlautarom1 and iamquang95 and removed request for Copilot March 23, 2026 10:42
@mskrzypkows mskrzypkows changed the title Beacon CLI tests feat(cli): beacon CLI tests Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the beacon-node CLI test suite into pluto-cli, implementing connectivity/latency/load/simulation checks against beacon endpoints (issue #233).

Changes:

  • Implemented full alpha test beacon command logic (test discovery, execution, scoring, JSON output, optional publish).
  • Added endpoint URL credential parsing + optional HTTP Basic Auth application for test requests.
  • Extended Duration wrapper to support ordering and nanosecond comparisons used by simulation evaluation.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
crates/cli/src/main.rs Initializes tracing for alpha test command path.
crates/cli/src/duration.rs Adds as_nanos, Ord, and conversion to std::time::Duration to support simulation metrics.
crates/cli/src/commands/test/mod.rs Beacon test case listing; adds endpoint URL credential parsing + basic auth; adjusts test filtering API; updates request RTT path.
crates/cli/src/commands/test/beacon.rs Replaces stub with full beacon test suite implementation (ping/measure/version/sync/peer-count/load/simulation).
crates/cli/Cargo.toml Adds tracing-subscriber dependency needed by CLI tracing init.
Cargo.lock Locks tracing-subscriber as a dependency of pluto-cli.
Comments suppressed due to low confidence (1)

crates/cli/src/commands/test/mod.rs:756

  • request_rtt returns Ok(rtt) even when status != expected_status (it only logs a warning). The beacon tests treat Ok(_) as success (e.g., Ping sets verdict Ok), so endpoints returning the wrong status can still be marked as passing. Consider returning an error (or a richer result containing both RTT and status) when the status code doesn't match expected_status, and update callers accordingly.
    let status = response.status();
    if status != expected_status {
        match response.text().await {
            Ok(body) if !body.is_empty() => tracing::warn!(
                status_code = status.as_u16(),
                expected_status_code = expected_status.as_u16(),
                endpoint = clean_url,
                body = body,
                "Unexpected status code"
            ),
            _ => tracing::warn!(
                status_code = status.as_u16(),
                expected_status_code = expected_status.as_u16(),
                endpoint = clean_url,
                "Unexpected status code"
            ),
        }
    }

    Ok(rtt)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@varex83
Copy link
Copy Markdown
Collaborator

varex83 commented Mar 23, 2026

Thanks for the PR! Can you fix the linter please?

@mskrzypkows
Copy link
Copy Markdown
Contributor Author

sure, I'm resolving rest copilot comments

@mskrzypkows
Copy link
Copy Markdown
Contributor Author

Addressed all @copilot comments

Copy link
Copy Markdown

Copilot AI commented Mar 24, 2026

@mskrzypkows I've opened a new pull request, #296, to work on those changes. Once the pull request is ready, I'll request review from you.

@mskrzypkows
Copy link
Copy Markdown
Contributor Author

Also added a docker compose to easier run beacon test, e.g.:

cargo run --bin pluto -- alpha test beacon --test-cases Ping,PingMeasure --endpoints http://localhost:5052

Copy link
Copy Markdown
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not fully review the code but I don't want to block any further. Left several comments, in particular regarding cancellation

mskrzypkows and others added 6 commits March 30, 2026 12:15
Co-authored-by: Lautaro Emanuel <31224949+emlautarom1@users.noreply.github.com>
Co-authored-by: Lautaro Emanuel <31224949+emlautarom1@users.noreply.github.com>
@mskrzypkows
Copy link
Copy Markdown
Contributor Author

I'll address the rest of the comments soon.

Copy link
Copy Markdown
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want to block on this one. There are a couple of things that can be addressed on future PRs. Before merging I would ask to move the .json files to a directory closer to their usage rather than having them at the top level.

Appreciate your work!

);

let (tx, mut rx) = mpsc::channel::<StdDuration>(i16::MAX as usize);
cancel_after(&cancel, cfg.load_test_duration);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a rule of thumb, you only cancel a CancellationToken if you own it, where "own" it means that you created it (not in the Rust sense of ownership). If you need to do local cancellation use .child_token() to create a local CancellationToken.


The reason for this is to avoid situations where the parent that passed a CancellationToken gets cancelled due to the child cancelling the token. For reference:

  • In Go, when you create a context you get the context itself + a CancelFunc, and only the former is passed to child functions/goroutines. Creating a child context does not grant the ability to cancel the parent.
  • In C#, a CancellationToken can only be created through a CancellationTokenSource, and only the former is passed to child functions/tasks, while the later is the only object that provides the Cancel() operation.

);

let (tx, mut rx) = mpsc::channel::<StdDuration>(i16::MAX as usize);
cancel_after(&cancel, cfg.load_test_duration);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, here in the Go implementation there is a local context pingCtx created from the arguments ctx. Here, ctx would be our cancel argument, but we're missing the equivalent of pingCtx (the local CancellationToken)

@mskrzypkows
Copy link
Copy Markdown
Contributor Author

I've pushed json files by mistake, removing them...

@mskrzypkows mskrzypkows requested a review from varex83 April 1, 2026 10:41
Copy link
Copy Markdown
Collaborator

@varex83 varex83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

One small thing, and it's GTG

@mskrzypkows mskrzypkows merged commit a4a2ee5 into main Apr 1, 2026
8 checks passed
@mskrzypkows mskrzypkows deleted the beacon_cli_tests branch April 1, 2026 14:42
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.

Implement cli test beacon

5 participants