Add non-standard-ports preset and test

This commit is contained in:
Joseph Mark 2017-07-14 10:42:56 +07:00
parent 4fea18d945
commit b975efa2bb
No known key found for this signature in database
GPG Key ID: 9BA8D1EE2E53C283
3 changed files with 36 additions and 0 deletions

View File

@ -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

View File

@ -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())
}
}

View File

@ -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