Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix rpc_eth_author test
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Sep 1, 2018
1 parent e5e6faf commit bc05784
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rpc/src/v1/tests/mocked/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,25 +359,27 @@ fn rpc_eth_author() {
let make_res = |addr| r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:x}", addr) + r#"","id":1}"#;
let tester = EthTester::default();

let req = r#"{
let request = r#"{
"jsonrpc": "2.0",
"method": "eth_coinbase",
"params": [],
"id": 1
}"#;

// No accounts - returns zero
assert_eq!(tester.io.handle_request_sync(req), Some(make_res(Address::zero())));
let response = r#"{"jsonrpc":"2.0","error":{"code":-32023,"message":"No accounts were found","data":"\"\""},"id":1}"#;

// No accounts - returns an error indicating that no accounts were found
assert_eq!(tester.io.handle_request_sync(request), Some(response.to_string()));

// Account set - return first account
let addr = tester.accounts_provider.new_account(&"123".into()).unwrap();
assert_eq!(tester.io.handle_request_sync(req), Some(make_res(addr)));
assert_eq!(tester.io.handle_request_sync(request), Some(make_res(addr)));

for i in 0..20 {
let addr = tester.accounts_provider.new_account(&format!("{}", i).into()).unwrap();
tester.miner.set_author(addr.clone(), None).unwrap();

assert_eq!(tester.io.handle_request_sync(req), Some(make_res(addr)));
assert_eq!(tester.io.handle_request_sync(request), Some(make_res(addr)));
}
}

Expand Down

0 comments on commit bc05784

Please sign in to comment.