diff --git a/parity/cli/presets/config.non-standard-ports.toml b/parity/cli/presets/config.non-standard-ports.toml new file mode 100644 index 000000000..9c826f36e --- /dev/null +++ b/parity/cli/presets/config.non-standard-ports.toml @@ -0,0 +1,10 @@ +# This config should be placed in following path: +# $HOME/Library/Application Support/io.parity.ethereum/config.toml + +[network] +# Parity will listen for connections on port 30305. +port = 30305 + +[rpc] +# JSON-RPC over HTTP will be accessible on port 8645. +port = 8645 \ No newline at end of file diff --git a/parity/cli/presets/mod.rs b/parity/cli/presets/mod.rs index 1242a7e88..4fe29174c 100644 --- a/parity/cli/presets/mod.rs +++ b/parity/cli/presets/mod.rs @@ -18,6 +18,7 @@ pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> { match arg.to_lowercase().as_ref() { "dev" => Ok(include_str!("./config.dev.toml")), "mining" => Ok(include_str!("./config.mining.toml")), + "non-standard-ports" => Ok(include_str!("./config.non-standard-ports.toml")), _ => Err(arg.clone()) } } \ No newline at end of file diff --git a/parity/configuration.rs b/parity/configuration.rs index 4ca5fb1e3..aec46cc6b 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -1616,6 +1616,31 @@ mod tests { } } + #[test] + fn test_non_standard_ports_preset() { + let args = vec!["parity", "preset", "non-standard-ports"]; + let conf = Configuration::parse(&args, None).unwrap(); + match conf.into_command().unwrap().cmd { + Cmd::Run(c) => { + assert_eq!(c.net_settings.network_port, 30305); + assert_eq!(c.net_settings.rpc_port, 8645); + }, + _ => panic!("Should be Cmd::Run"), + } + } + + #[test] + fn test_override_preset() { + let args = vec!["parity", "preset", "mining", "--min-peers=99"]; + let conf = Configuration::parse(&args, None).unwrap(); + match conf.into_command().unwrap().cmd { + Cmd::Run(c) => { + assert_eq!(c.net_conf.min_peers, 99); + }, + _ => panic!("Should be Cmd::Run"), + } + } + #[test] fn should_apply_ports_shift() { // given