diff --git a/client/src/mock_sender.rs b/client/src/mock_sender.rs index 8af926bdfe..1789006b60 100644 --- a/client/src/mock_sender.rs +++ b/client/src/mock_sender.rs @@ -2,7 +2,10 @@ use { crate::{ client_error::Result, rpc_request::RpcRequest, - rpc_response::{Response, RpcResponseContext, RpcVersionInfo}, + rpc_response::{ + Response, RpcBlockProduction, RpcBlockProductionRange, RpcResponseContext, + RpcVersionInfo, + }, rpc_sender::RpcSender, }, serde_json::{json, Number, Value}, @@ -148,6 +151,19 @@ impl RpcSender for MockSender { feature_set: Some(version.feature_set), }) } + "getBlockProduction" => { + let map = vec![(PUBKEY.to_string(), (1, 1))].into_iter().collect(); + json!(Response { + context: RpcResponseContext { slot: 1 }, + value: RpcBlockProduction { + by_identity: map, + range: RpcBlockProductionRange { + first_slot: 0, + last_slot: 0, + }, + }, + }) + } _ => Value::Null, }; Ok(val) diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index 97bc442783..0424066d43 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -482,7 +482,7 @@ impl RpcClient { &self, config: RpcBlockProductionConfig, ) -> RpcResult { - self.send(RpcRequest::GetBlockProduction, json!(config)) + self.send(RpcRequest::GetBlockProduction, json!([config])) } pub fn get_stake_activation( @@ -2245,4 +2245,23 @@ mod tests { let rpc_client = RpcClient::new_mock("succeeds".to_string()); thread::spawn(move || rpc_client); } + + // Regression test that the get_block_production_with_config + // method internally creates the json params array correctly. + #[test] + fn get_block_production_with_config_no_error() -> ClientResult<()> { + let rpc_client = RpcClient::new_mock("succeeds".to_string()); + + let config = RpcBlockProductionConfig { + identity: None, + range: None, + commitment: None, + }; + + let prod = rpc_client.get_block_production_with_config(config)?.value; + + assert!(!prod.by_identity.is_empty()); + + Ok(()) + } }