Add mining preset and test

This commit is contained in:
Joseph Mark 2017-07-14 10:15:39 +07:00
parent 0f37261dbf
commit 4fea18d945
No known key found for this signature in database
GPG Key ID: 9BA8D1EE2E53C283
5 changed files with 57 additions and 10 deletions

View File

@ -0,0 +1,34 @@
# 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
# Parity will maintain at most 100 peers.
max_peers = 100
[ipc]
# You won't be able to use IPC to interact with Parity.
disable = true
[dapps]
# You won't be able to access any web Dapps.
disable = true
[mining]
# Prepare a block to seal even when there are no miners connected.
force_sealing = true
# New pending block will be created for all transactions (both local and external).
reseal_on_txs = "all"
# New pending block will be created only once per 4000 milliseconds.
reseal_min_period = 4000
# Parity will keep/relay at most 2048 transactions in queue.
tx_queue_size = 2048
[footprint]
# If defined will never use more then 256MB for all caches. (Overrides other cache settings).
cache_size = 256
[misc]
# Logging pattern (`<module>=<level>`, e.g. `own_tx=trace`).
logging = "miner=trace,own_tx=trace"

View File

@ -1,7 +0,0 @@
[parity]
mode = "dark"
chain = "kovan"
[mining]
force_sealing = true
reseal_min_period = 2000

View File

@ -1,3 +0,0 @@
[parity]
mode = "passive"
chain = "homestead"

View File

@ -17,6 +17,7 @@
pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> { pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> {
match arg.to_lowercase().as_ref() { match arg.to_lowercase().as_ref() {
"dev" => Ok(include_str!("./config.dev.toml")), "dev" => Ok(include_str!("./config.dev.toml")),
"mining" => Ok(include_str!("./config.mining.toml")),
_ => Err(arg.clone()) _ => Err(arg.clone())
} }
} }

View File

@ -1594,6 +1594,28 @@ mod tests {
} }
} }
#[test]
fn test_mining_preset() {
let args = vec!["parity", "preset", "mining"];
let conf = Configuration::parse(&args, None).unwrap();
match conf.into_command().unwrap().cmd {
Cmd::Run(c) => {
assert_eq!(c.net_conf.min_peers, 50);
assert_eq!(c.net_conf.max_peers, 100);
assert_eq!(c.ipc_conf.enabled, false);
assert_eq!(c.dapps_conf.enabled, false);
assert_eq!(c.miner_options.force_sealing, true);
assert_eq!(c.miner_options.reseal_on_external_tx, true);
assert_eq!(c.miner_options.reseal_on_own_tx, true);
assert_eq!(c.miner_options.reseal_min_period, Duration::from_millis(4000));
assert_eq!(c.miner_options.tx_queue_size, 2048);
assert_eq!(c.cache_config, CacheConfig::new_with_total_cache_size(256));
assert_eq!(c.logger_config.mode.unwrap(), "miner=trace,own_tx=trace");
},
_ => panic!("Should be Cmd::Run"),
}
}
#[test] #[test]
fn should_apply_ports_shift() { fn should_apply_ports_shift() {
// given // given