Add port and gossip options to solana-test-validator (#16696) (#16698)

(cherry picked from commit 0924c2d070)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
mergify[bot]
2021-04-21 03:46:52 +00:00
committed by GitHub
parent bbd8bd2e74
commit e15ddbb979
5 changed files with 198 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
#![allow(clippy::integer_arithmetic)]
pub use solana_core::test_validator;
pub use solana_core::{cluster_info::MINIMUM_VALIDATOR_PORT_RANGE_WIDTH, test_validator};
use {
console::style,
indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle},
@@ -75,6 +75,22 @@ pub fn port_validator(port: String) -> Result<(), String> {
.map_err(|e| format!("{:?}", e))
}
pub fn port_range_validator(port_range: String) -> Result<(), String> {
if let Some((start, end)) = solana_net_utils::parse_port_range(&port_range) {
if end - start < MINIMUM_VALIDATOR_PORT_RANGE_WIDTH {
Err(format!(
"Port range is too small. Try --dynamic-port-range {}-{}",
start,
start + MINIMUM_VALIDATOR_PORT_RANGE_WIDTH
))
} else {
Ok(())
}
} else {
Err("Invalid port range".to_string())
}
}
/// Creates a new process bar for processing that will take an unknown amount of time
pub fn new_spinner_progress_bar() -> ProgressBar {
let progress_bar = ProgressBar::new(42);