config: don't allow dev chain with force sealing option

This commit is contained in:
Guanqun Lu 2017-07-01 23:20:49 +08:00
parent f22745eb0a
commit 9241c6a9b5

View File

@ -515,6 +515,10 @@ impl Configuration {
} }
fn miner_options(&self, reseal_min_period: u64) -> Result<MinerOptions, String> { fn miner_options(&self, reseal_min_period: u64) -> Result<MinerOptions, String> {
if self.args.flag_force_sealing && reseal_min_period == 0 {
return Err("Force sealing can't be used with reseal_min_period = 0".into());
}
let reseal = self.args.flag_reseal_on_txs.parse::<ResealPolicy>()?; let reseal = self.args.flag_reseal_on_txs.parse::<ResealPolicy>()?;
let options = MinerOptions { let options = MinerOptions {
@ -1334,6 +1338,13 @@ mod tests {
assert_eq!(conf3.miner_options(min_period).unwrap(), mining_options); assert_eq!(conf3.miner_options(min_period).unwrap(), mining_options);
} }
#[test]
fn should_fail_on_force_reseal_and_reseal_min_period() {
let conf = parse(&["parity", "--chain", "dev", "--force-sealing"]);
assert!(conf.miner_options(0).is_err());
}
#[test] #[test]
fn should_parse_updater_options() { fn should_parse_updater_options() {
// when // when