Merge pull request #5965 from guanqun/fix-force-seal

config: don't allow dev chain with force sealing option
This commit is contained in:
Marek Kotewicz 2017-07-06 11:20:06 +02:00 committed by GitHub
commit a78a89b13a

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