Skip to content
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

feat: accept 'esme' as network name on cli #4401

Merged
merged 3 commits into from
Aug 8, 2022
Merged
Changes from 2 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
28 changes: 10 additions & 18 deletions common/src/configuration/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FromStr for Network {
"localnet" => Ok(LocalNet),
"igor" => Ok(Igor),
"dibbler" => Ok(Dibbler),
"esmeralda" => Ok(Esmeralda),
"esmeralda" | "esme" => Ok(Esmeralda),
invalid => Err(ConfigurationError::new(
"network",
Some(value.to_string()),
Expand Down Expand Up @@ -164,24 +164,16 @@ mod test {

#[test]
fn network_from_str() {
let mainnet_str = "mainnet";
let localnet_str = "localnet";
let ridcully_str = "ridcully";
let stibbons_str = "stibbons";
let weatherwas_str = "weatherwax";
let igor_str = "igor";
let dibbler_str = "dibbler";
let esmeralda_str = "esmeralda";

// test .from_str()
assert_eq!(Network::from_str(mainnet_str).unwrap(), Network::MainNet);
assert_eq!(Network::from_str(localnet_str).unwrap(), Network::LocalNet);
assert_eq!(Network::from_str(ridcully_str).unwrap(), Network::Ridcully);
assert_eq!(Network::from_str(stibbons_str).unwrap(), Network::Stibbons);
assert_eq!(Network::from_str(weatherwas_str).unwrap(), Network::Weatherwax);
assert_eq!(Network::from_str(igor_str).unwrap(), Network::Igor);
assert_eq!(Network::from_str(dibbler_str).unwrap(), Network::Dibbler);
assert_eq!(Network::from_str(esmeralda_str).unwrap(), Network::Esmeralda);
assert_eq!(Network::from_str("mainnet").unwrap(), Network::MainNet);
assert_eq!(Network::from_str("localnet").unwrap(), Network::LocalNet);
assert_eq!(Network::from_str("ridcully").unwrap(), Network::Ridcully);
assert_eq!(Network::from_str("stibbons").unwrap(), Network::Stibbons);
assert_eq!(Network::from_str("weatherwax").unwrap(), Network::Weatherwax);
assert_eq!(Network::from_str("igor").unwrap(), Network::Igor);
assert_eq!(Network::from_str("dibbler").unwrap(), Network::Dibbler);
assert_eq!(Network::from_str("esmeralda").unwrap(), Network::Esmeralda);
assert_eq!(Network::from_str("esme").unwrap(), Network::Esmeralda);
// catch error case
let err_network = Network::from_str("invalid network");
assert!(err_network.is_err());
Expand Down