Skip to content

Start test validator bound to localhost by default (rather than all interfaces) #5862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions validator/src/bin/solana-test-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ fn main() {
exit(1);
})
});
let bind_address = matches.value_of("bind_address").map(|bind_address| {
solana_net_utils::parse_host(bind_address).unwrap_or_else(|err| {
eprintln!("Failed to parse --bind-address: {err}");
exit(1);
})
let bind_address = solana_net_utils::parse_host(
matches
.value_of("bind_address")
.expect("Bind address has default value"),
)
.unwrap_or_else(|err| {
eprintln!("Failed to parse --bind-address: {err}");
exit(1);
});
let compute_unit_limit = value_t!(matches, "compute_unit_limit", u64).ok();

Expand Down Expand Up @@ -552,9 +555,7 @@ fn main() {
genesis.port_range(dynamic_port_range);
}

if let Some(bind_address) = bind_address {
genesis.bind_ip_addr(bind_address);
}
genesis.bind_ip_addr(bind_address);

if matches.is_present("geyser_plugin_config") {
genesis.geyser_plugin_config_files = Some(
Expand Down
4 changes: 2 additions & 2 deletions validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,8 @@ pub fn test_app<'a>(version: &'a str, default_args: &'a DefaultTestArgs) -> App<
.value_name("HOST")
.takes_value(true)
.validator(solana_net_utils::is_host)
.default_value("0.0.0.0")
.help("IP address to bind the validator ports [default: 0.0.0.0]"),
.default_value("127.0.0.1")
.help("IP address to bind the validator ports [default: 127.0.0.1]"),
)
.arg(
Arg::with_name("clone_account")
Expand Down
Loading