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
This commit is contained in:
joshua-mir 2019-01-15 09:36:55 +01:00 committed by Tomasz Drwięga
parent 53a04e1686
commit 0edf8e3f1b
2 changed files with 4 additions and 4 deletions

View File

@ -129,8 +129,8 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
let r = match (self.allow_perm_unlock, duration) { let r = match (self.allow_perm_unlock, duration) {
(false, None) => store.unlock_account_temporarily(account, account_pass.into()), (false, None) => store.unlock_account_temporarily(account, account_pass.into()),
(false, _) => return Err(errors::unsupported( (false, _) => return Err(errors::unsupported(
"Time-unlocking is only supported in --geth compatibility mode.", "Time-unlocking is not supported when permanent unlock is disabled.",
Some("Restart your client with --geth flag or use personal_sendTransaction instead."), Some("Use personal_sendTransaction or enable permanent unlocking, instead."),
)), )),
(true, Some(0)) => store.unlock_account_permanently(account, account_pass.into()), (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())), (true, Some(d)) => store.unlock_account_timed(account, account_pass.into(), Duration::from_secs(d.into())),

View File

@ -303,7 +303,7 @@ fn ec_recover_invalid_signature() {
} }
#[test] #[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 tester = setup();
let address = tester.accounts.new_account(&"password123".into()).unwrap(); 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 "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_eq!(tester.io.handle_request_sync(&request), Some(response.into()));
assert!(tester.accounts.sign(address, None, Default::default()).is_err(), "Should not unlock account."); assert!(tester.accounts.sign(address, None, Default::default()).is_err(), "Should not unlock account.");