Add insecure presets and tests

This commit is contained in:
Joseph Mark 2017-07-17 13:03:57 +07:00
parent b975efa2bb
commit 360f1fa34f
No known key found for this signature in database
GPG Key ID: 9BA8D1EE2E53C283
6 changed files with 73 additions and 6 deletions

View File

@ -0,0 +1,16 @@
[parity]
no_consensus = true
chain = "dev"
[mining]
reseal_min_period = 0
min_gas_price = 0
[rpc]
interface = "all"
apis = ["all"]
hosts = ["all"]
[ipfs]
enable = false # this is the default
hosts = ["all"]

View File

@ -0,0 +1,11 @@
[parity]
no_consensus = true
[rpc]
interface = "all"
apis = ["all"]
hosts = ["all"]
[ipfs]
enable = false # this is the default
hosts = ["all"]

View File

@ -1,6 +1,3 @@
# This config should be placed in following path:
# $HOME/Library/Application Support/io.parity.ethereum/config.toml
[network]
# Parity will try to maintain connection to at least 50 peers.
min_peers = 50

View File

@ -1,6 +1,3 @@
# 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

View File

@ -19,6 +19,8 @@ pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> {
"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")),
"insecure" => Ok(include_str!("./config.insecure.toml")),
"dev-insecure" => Ok(include_str!("./config.dev-insecure.toml")),
_ => Err(arg.clone())
}
}

View File

@ -1587,6 +1587,7 @@ mod tests {
let conf = Configuration::parse(&args, None).unwrap();
match conf.into_command().unwrap().cmd {
Cmd::Run(c) => {
assert_eq!(c.net_settings.chain, "dev");
assert_eq!(c.gas_pricer, GasPricerConfig::Fixed(0.into()));
assert_eq!(c.miner_options.reseal_min_period, Duration::from_millis(0));
},
@ -1629,6 +1630,49 @@ mod tests {
}
}
#[test]
fn test_insecure_preset() {
let args = vec!["parity", "preset", "insecure"];
let conf = Configuration::parse(&args, None).unwrap();
match conf.into_command().unwrap().cmd {
Cmd::Run(c) => {
assert_eq!(c.update_policy.require_consensus, false);
assert_eq!(c.net_settings.rpc_interface, "0.0.0.0");
match c.http_conf.apis {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
// "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
assert_eq!(c.ipfs_conf.hosts, None);
},
_ => panic!("Should be Cmd::Run"),
}
}
#[test]
fn test_dev_insecure_preset() {
let args = vec!["parity", "preset", "dev-insecure"];
let conf = Configuration::parse(&args, None).unwrap();
match conf.into_command().unwrap().cmd {
Cmd::Run(c) => {
assert_eq!(c.net_settings.chain, "dev");
assert_eq!(c.gas_pricer, GasPricerConfig::Fixed(0.into()));
assert_eq!(c.miner_options.reseal_min_period, Duration::from_millis(0));
assert_eq!(c.update_policy.require_consensus, false);
assert_eq!(c.net_settings.rpc_interface, "0.0.0.0");
match c.http_conf.apis {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
// "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
assert_eq!(c.ipfs_conf.hosts, None);
},
_ => panic!("Should be Cmd::Run"),
}
}
#[test]
fn test_override_preset() {
let args = vec!["parity", "preset", "mining", "--min-peers=99"];