From 058dae064184b63071828024a894b2590f7ea31a Mon Sep 17 00:00:00 2001 From: Yeongjong Pyo Date: Wed, 7 May 2025 14:00:56 +0900 Subject: [PATCH] Add requires --http when using vc subcommands --http-port (#7405) Prevent running `lighthouse vc --http-port ` without `--http`. Issue: https://github.com/sigp/lighthouse/issues/7402 Added requires `--http` when using `lighthouse vc --http-port `. Implemented a test code for this issue. --- lighthouse/tests/validator_client.rs | 8 ++++++++ validator_client/src/cli.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/lighthouse/tests/validator_client.rs b/lighthouse/tests/validator_client.rs index 6e579f63c1..f99fc3c460 100644 --- a/lighthouse/tests/validator_client.rs +++ b/lighthouse/tests/validator_client.rs @@ -317,6 +317,14 @@ fn missing_unencrypted_http_transport_flag() { .with_config(|config| assert_eq!(config.http_api.listen_addr, addr)); } #[test] +#[should_panic] +fn missing_http_http_port_flag() { + CommandLineTest::new() + .flag("http-port", Some("9090")) + .run() + .with_config(|config| assert_eq!(config.http_api.listen_port, 9090)); +} +#[test] fn http_port_flag() { CommandLineTest::new() .flag("http", None) diff --git a/validator_client/src/cli.rs b/validator_client/src/cli.rs index 950d08a028..cdbf9f8472 100644 --- a/validator_client/src/cli.rs +++ b/validator_client/src/cli.rs @@ -219,6 +219,7 @@ pub struct ValidatorClient { #[clap( long, + requires = "http", value_name = "PORT", default_value_t = 5062, help = "Set the listen TCP port for the RESTful HTTP API server.",