Add test for RPC side
This commit is contained in:
parent
7c054d2da0
commit
dba8cf3a3b
@ -131,7 +131,7 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
|
||||
let store = take_weak!(self.accounts);
|
||||
let addr: Address = addr.into();
|
||||
|
||||
store.remove_address(addr, name))
|
||||
store.remove_address(addr)
|
||||
.expect("remove_address always returns Ok; qed");
|
||||
Ok(true)
|
||||
}
|
||||
|
@ -152,3 +152,32 @@ fn should_be_able_to_kill_account() {
|
||||
let accounts = tester.accounts.accounts().unwrap();
|
||||
assert_eq!(accounts.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_be_able_to_remove_address() {
|
||||
let tester = setup();
|
||||
|
||||
// add an address
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_setAccountName", "params": ["0x000baba1000baba2000baba3000baba4000baba5", "Test"], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
let res = tester.io.handle_request_sync(&request);
|
||||
assert_eq!(res, Some(response.into()));
|
||||
|
||||
// verify it exists
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_accountsInfo", "params": [], "id": 2}"#;
|
||||
let res = tester.io.handle_request_sync(request);
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"0x000baba1000baba2000baba3000baba4000baba5":{"meta":"{}","name":"Test","uuid":null}},"id":2}"#;
|
||||
assert_eq!(res, Some(response.into()));
|
||||
|
||||
// remove the address
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_removeAddress", "params": ["0x000baba1000baba2000baba3000baba4000baba5"], "id": 3}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":3}"#;
|
||||
let res = tester.io.handle_request_sync(&request);
|
||||
assert_eq!(res, Some(response.into()));
|
||||
|
||||
// verify empty
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "parity_accountsInfo", "params": [], "id": 4}"#;
|
||||
let res = tester.io.handle_request_sync(request);
|
||||
let response = r#"{"jsonrpc":"2.0","result":{},"id":4}"#;
|
||||
assert_eq!(res, Some(response.into()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user