From 0edf8e3f1b37c386988a17292b8662aea8c86bbd Mon Sep 17 00:00:00 2001 From: joshua-mir <43032097+joshua-mir@users.noreply.github.com> Date: Tue, 15 Jan 2019 09:36:55 +0100 Subject: [PATCH] Align personal_unlockAccount behaviour when permanent unlock is disabled (#10060) * align with docs > If permanent unlocking is disabled (the default) then the duration argument will be ignored, and the account will be unlocked for a single signing. Current behaviour throws an error that is no longer relevant. * fix test * Change back to throwing error * Fix test again * formatting * oops * whitespace fixes --- rpc/src/v1/impls/personal.rs | 4 ++-- rpc/src/v1/tests/mocked/personal.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 56135544a..abaebc3d0 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -129,8 +129,8 @@ impl Personal for PersonalClient { let r = match (self.allow_perm_unlock, duration) { (false, None) => store.unlock_account_temporarily(account, account_pass.into()), (false, _) => return Err(errors::unsupported( - "Time-unlocking is only supported in --geth compatibility mode.", - Some("Restart your client with --geth flag or use personal_sendTransaction instead."), + "Time-unlocking is not supported when permanent unlock is disabled.", + Some("Use personal_sendTransaction or enable permanent unlocking, instead."), )), (true, Some(0)) => store.unlock_account_permanently(account, account_pass.into()), (true, Some(d)) => store.unlock_account_timed(account, account_pass.into(), Duration::from_secs(d.into())), diff --git a/rpc/src/v1/tests/mocked/personal.rs b/rpc/src/v1/tests/mocked/personal.rs index b74553bc7..bdf606741 100644 --- a/rpc/src/v1/tests/mocked/personal.rs +++ b/rpc/src/v1/tests/mocked/personal.rs @@ -303,7 +303,7 @@ fn ec_recover_invalid_signature() { } #[test] -fn should_unlock_not_account_temporarily_if_allow_perm_is_disabled() { +fn should_not_unlock_account_temporarily_if_allow_perm_is_disabled() { let tester = setup(); let address = tester.accounts.new_account(&"password123".into()).unwrap(); @@ -317,7 +317,7 @@ fn should_unlock_not_account_temporarily_if_allow_perm_is_disabled() { ], "id": 1 }"#; - let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Time-unlocking is only supported in --geth compatibility mode.","data":"Restart your client with --geth flag or use personal_sendTransaction instead."},"id":1}"#; + let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Time-unlocking is not supported when permanent unlock is disabled.","data":"Use personal_sendTransaction or enable permanent unlocking, instead."},"id":1}"#; assert_eq!(tester.io.handle_request_sync(&request), Some(response.into())); assert!(tester.accounts.sign(address, None, Default::default()).is_err(), "Should not unlock account.");