add set_sealer rpc test

This commit is contained in:
keorn 2016-11-30 15:01:43 +00:00
parent 73e7908325
commit ca87d2cde9
3 changed files with 22 additions and 3 deletions

View File

@ -50,7 +50,7 @@ fn sync_provider() -> Arc<TestSyncProvider> {
}))
}
fn miner_service(spec: &Spec) -> Arc<Miner> {
fn miner_service(spec: &Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
Miner::new(
MinerOptions {
new_work_notify: vec![],
@ -69,6 +69,7 @@ fn miner_service(spec: &Spec) -> Arc<Miner> {
},
GasPricer::new_fixed(20_000_000_000u64.into()),
&spec,
Some(accounts),
)
}
@ -116,7 +117,7 @@ impl EthTester {
let dir = RandomTempPath::new();
let account_provider = account_provider();
spec.engine.register_account_provider(account_provider.clone());
let miner_service = miner_service(&spec);
let miner_service = miner_service(&spec, account_provider.clone());
let snapshot_service = snapshot_service();
let db_config = ::util::kvdb::DatabaseConfig::with_columns(::ethcore::db::NUM_COLUMNS);

View File

@ -41,10 +41,11 @@ pub struct TestMinerService {
pub pending_receipts: Mutex<BTreeMap<H256, Receipt>>,
/// Last nonces.
pub last_nonces: RwLock<HashMap<Address, U256>>,
/// Password held by Engine.
pub password: RwLock<String>,
min_gas_price: RwLock<U256>,
gas_range_target: RwLock<(U256, U256)>,
password: RwLock<String>,
author: RwLock<Address>,
extra_data: RwLock<Bytes>,
limit: RwLock<usize>,

View File

@ -106,6 +106,23 @@ fn rpc_parity_set_author() {
assert_eq!(miner.author(), Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap());
}
#[test]
fn rpc_parity_set_sealer() {
let miner = miner_service();
let client = client_service();
let network = network_service();
let io = IoHandler::new();
io.add_delegate(parity_set_client(&client, &miner, &network).to_delegate());
let request = r#"{"jsonrpc": "2.0", "method": "parity_setSealer", "params":["0xcd1722f3947def4cf144679da39c4c32bdc35681", "password"], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
assert_eq!(miner.author(), Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap());
assert_eq!(*miner.password.read(), "password".to_string());
}
#[test]
fn rpc_parity_set_transactions_limit() {
let miner = miner_service();