Fix serialization of parameters in RpcClient::get_block_production_with_config (#18998)
Params must be an array or null.
This commit is contained in:
@ -5,7 +5,8 @@ use {
|
|||||||
client_error::Result,
|
client_error::Result,
|
||||||
rpc_request::RpcRequest,
|
rpc_request::RpcRequest,
|
||||||
rpc_response::{
|
rpc_response::{
|
||||||
Response, RpcResponseContext, RpcSimulateTransactionResult, RpcVersionInfo,
|
Response, RpcBlockProduction, RpcBlockProductionRange, RpcResponseContext,
|
||||||
|
RpcSimulateTransactionResult, RpcVersionInfo,
|
||||||
},
|
},
|
||||||
rpc_sender::RpcSender,
|
rpc_sender::RpcSender,
|
||||||
},
|
},
|
||||||
@ -186,6 +187,19 @@ impl RpcSender for MockSender {
|
|||||||
feature_set: Some(version.feature_set),
|
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,
|
_ => Value::Null,
|
||||||
};
|
};
|
||||||
Ok(val)
|
Ok(val)
|
||||||
|
@ -895,7 +895,7 @@ impl RpcClient {
|
|||||||
&self,
|
&self,
|
||||||
config: RpcBlockProductionConfig,
|
config: RpcBlockProductionConfig,
|
||||||
) -> RpcResult<RpcBlockProduction> {
|
) -> RpcResult<RpcBlockProduction> {
|
||||||
self.send(RpcRequest::GetBlockProduction, json!(config))
|
self.send(RpcRequest::GetBlockProduction, json!([config]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_stake_activation(
|
pub fn get_stake_activation(
|
||||||
@ -2658,4 +2658,23 @@ mod tests {
|
|||||||
let rpc_client = RpcClient::new_mock("succeeds".to_string());
|
let rpc_client = RpcClient::new_mock("succeeds".to_string());
|
||||||
thread::spawn(move || rpc_client);
|
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(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user