Merge branch 'master' into rpc-middleware
Conflicts: Cargo.lock rpc/src/v1/tests/mocked/parity_accounts.rs
This commit is contained in:
@@ -104,7 +104,7 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
|
||||
let account: Address = account.into();
|
||||
|
||||
take_weak!(self.accounts)
|
||||
.test_password(&account, password)
|
||||
.test_password(&account, &password)
|
||||
.map_err(|e| errors::account("Could not fetch account info.", e))
|
||||
}
|
||||
|
||||
@@ -117,6 +117,15 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
|
||||
.map_err(|e| errors::account("Could not fetch account info.", e))
|
||||
}
|
||||
|
||||
fn kill_account(&self, account: RpcH160, password: String) -> Result<bool, Error> {
|
||||
try!(self.active());
|
||||
let account: Address = account.into();
|
||||
take_weak!(self.accounts)
|
||||
.kill_account(&account, &password)
|
||||
.map(|_| true)
|
||||
.map_err(|e| errors::account("Could not delete account.", e))
|
||||
}
|
||||
|
||||
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool, Error> {
|
||||
try!(self.active());
|
||||
let store = take_weak!(self.accounts);
|
||||
|
||||
@@ -116,7 +116,6 @@ fn should_be_able_to_set_meta() {
|
||||
assert_eq!(res, Some(response));
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn rpc_parity_set_dapps_accounts() {
|
||||
// given
|
||||
@@ -131,3 +130,25 @@ fn rpc_parity_set_dapps_accounts() {
|
||||
// then
|
||||
assert_eq!(tester.accounts.dapps_addresses("app1".into()).unwrap(), vec![10.into()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_be_able_to_kill_account() {
|
||||
let tester = setup();
|
||||
tester.accounts.new_account("password").unwrap();
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 1);
|
||||
let address = accounts[0];
|
||||
|
||||
let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0xf00baba2f00baba2f00baba2f00baba2f00baba2"], "id": 1}}"#);
|
||||
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":null},"id":1}"#;
|
||||
let res = tester.io.handle_request_sync(&request);
|
||||
assert_eq!(res, Some(response.into()));
|
||||
|
||||
let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0x{}", "password"], "id": 1}}"#, address.hex());
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
let res = tester.io.handle_request_sync(&request);
|
||||
assert_eq!(res, Some(response.into()));
|
||||
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 0);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,11 @@ build_rpc_trait! {
|
||||
#[rpc(name = "parity_changePassword")]
|
||||
fn change_password(&self, H160, String, String) -> Result<bool, Error>;
|
||||
|
||||
/// Permanently deletes an account.
|
||||
/// Arguments: `account`, `password`.
|
||||
#[rpc(name = "parity_killAccount")]
|
||||
fn kill_account(&self, H160, String) -> Result<bool, Error>;
|
||||
|
||||
/// Set an account's name.
|
||||
#[rpc(name = "parity_setAccountName")]
|
||||
fn set_account_name(&self, H160, String) -> Result<bool, Error>;
|
||||
|
||||
Reference in New Issue
Block a user