RpcClient::send<T> now supports client-defined RPC methods via RpcRequest::Custom

This commit is contained in:
Michael Vines
2021-07-23 14:39:38 -07:00
parent 1ee64afb12
commit f264511585
3 changed files with 38 additions and 16 deletions

View File

@@ -2575,6 +2575,7 @@ mod tests {
let signature = rpc_client.send_transaction(&tx);
assert!(signature.is_err());
}
#[test]
fn test_get_recent_blockhash() {
let rpc_client = RpcClient::new_mock("succeeds".to_string());
@@ -2589,6 +2590,20 @@ mod tests {
assert!(rpc_client.get_recent_blockhash().is_err());
}
#[test]
fn test_custom_request() {
let rpc_client = RpcClient::new_mock("succeeds".to_string());
let slot = rpc_client.get_slot().unwrap();
assert_eq!(slot, 0);
let custom_slot = rpc_client
.send::<Slot>(RpcRequest::Custom { method: "getSlot" }, Value::Null)
.unwrap();
assert_eq!(slot, custom_slot);
}
#[test]
fn test_get_signature_status() {
let signature = Signature::default();