From 10bdfe6926e52138bfa5e158806565e72acca27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 22 Jul 2016 14:47:31 +0200 Subject: [PATCH] Disabling signer when in geth-compatibility mode (#1676) --- parity/configuration.rs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/parity/configuration.rs b/parity/configuration.rs index af28a8665..ba0ae8bfb 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -562,8 +562,15 @@ impl Configuration { } pub fn signer_enabled(&self) -> bool { - (self.args.flag_unlock.is_none() && !self.args.flag_no_signer) || - self.args.flag_force_signer + if self.args.flag_force_signer { + return true; + } + + let signer_disabled = self.args.flag_unlock.is_some() || + self.args.flag_geth || + self.args.flag_no_signer; + + return !signer_disabled; } pub fn log_settings(&self) -> LogSettings { @@ -660,5 +667,29 @@ mod tests { assert_eq!(conf2.rpc_hosts(), None); assert_eq!(conf3.rpc_hosts(), Some(vec!["ethcore.io".into(), "something.io".into()])); } + + #[test] + fn should_disable_signer_in_geth_compat() { + // given + + // when + let conf0 = parse(&["parity", "--geth"]); + let conf1 = parse(&["parity", "--geth", "--force-signer"]); + + // then + assert_eq!(conf0.signer_enabled(), false); + assert_eq!(conf1.signer_enabled(), true); + } + + #[test] + fn should_disable_signer_when_account_is_unlocked() { + // given + + // when + let conf0 = parse(&["parity", "--unlock", "0x0"]); + + // then + assert_eq!(conf0.signer_enabled(), false); + } }