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:
parent
53a04e1686
commit
0edf8e3f1b
@ -129,8 +129,8 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
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())),
|
||||
|
@ -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.");
|
||||
|
Loading…
Reference in New Issue
Block a user