Fix serialization of parameters in RpcClient::get_block_production_with_config (#18998)

Params must be an array or null.
This commit is contained in:
Brian Anderson
2021-07-30 15:20:33 -05:00
committed by GitHub
parent fe1ee49807
commit 58f395257b
2 changed files with 35 additions and 2 deletions

View File

@@ -895,7 +895,7 @@ impl RpcClient {
&self,
config: RpcBlockProductionConfig,
) -> RpcResult<RpcBlockProduction> {
self.send(RpcRequest::GetBlockProduction, json!(config))
self.send(RpcRequest::GetBlockProduction, json!([config]))
}
pub fn get_stake_activation(
@@ -2658,4 +2658,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(())
}
}