Rename JSON RPC getLastId to getRecentBlockHash
This commit is contained in:
committed by
Greg Fitzgerald
parent
258cf21416
commit
85159a0eb4
@@ -155,7 +155,7 @@ pub trait RpcSol {
|
||||
#[rpc(meta, name = "getBalance")]
|
||||
fn get_balance(&self, _: Self::Metadata, _: String) -> Result<u64>;
|
||||
|
||||
#[rpc(meta, name = "getLastId")]
|
||||
#[rpc(meta, name = "getRecentBlockHash")]
|
||||
fn get_recent_block_hash(&self, _: Self::Metadata) -> Result<String>;
|
||||
|
||||
#[rpc(meta, name = "getSignatureStatus")]
|
||||
@@ -532,7 +532,7 @@ mod tests {
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let (io, meta, block_hash, _alice) = start_rpc_handler_with_tx(bob_pubkey);
|
||||
|
||||
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getLastId"}}"#);
|
||||
let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getRecentBlockHash"}}"#);
|
||||
let res = io.handle_request_sync(&req, meta);
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","result":"{}","id":1}}"#, block_hash);
|
||||
let expected: Response =
|
||||
|
@@ -64,7 +64,7 @@ impl MockRpcClient {
|
||||
let n = if self.addr == "airdrop" { 0 } else { 50 };
|
||||
Value::Number(Number::from(n))
|
||||
}
|
||||
RpcRequest::GetLastId => Value::String(PUBKEY.to_string()),
|
||||
RpcRequest::GetRecentBlockHash => Value::String(PUBKEY.to_string()),
|
||||
RpcRequest::GetSignatureStatus => {
|
||||
let str = if self.addr == "account_in_use" {
|
||||
"AccountInUse"
|
||||
|
@@ -129,7 +129,7 @@ pub enum RpcRequest {
|
||||
ConfirmTransaction,
|
||||
GetAccountInfo,
|
||||
GetBalance,
|
||||
GetLastId,
|
||||
GetRecentBlockHash,
|
||||
GetSignatureStatus,
|
||||
GetTransactionCount,
|
||||
RequestAirdrop,
|
||||
@@ -149,7 +149,7 @@ impl RpcRequest {
|
||||
RpcRequest::ConfirmTransaction => "confirmTransaction",
|
||||
RpcRequest::GetAccountInfo => "getAccountInfo",
|
||||
RpcRequest::GetBalance => "getBalance",
|
||||
RpcRequest::GetLastId => "getLastId",
|
||||
RpcRequest::GetRecentBlockHash => "getRecentBlockHash",
|
||||
RpcRequest::GetSignatureStatus => "getSignatureStatus",
|
||||
RpcRequest::GetTransactionCount => "getTransactionCount",
|
||||
RpcRequest::RequestAirdrop => "requestAirdrop",
|
||||
@@ -217,9 +217,9 @@ mod tests {
|
||||
let request = test_request.build_request_json(1, Some(addr));
|
||||
assert_eq!(request["method"], "getBalance");
|
||||
|
||||
let test_request = RpcRequest::GetLastId;
|
||||
let test_request = RpcRequest::GetRecentBlockHash;
|
||||
let request = test_request.build_request_json(1, None);
|
||||
assert_eq!(request["method"], "getLastId");
|
||||
assert_eq!(request["method"], "getRecentBlockHash");
|
||||
|
||||
let test_request = RpcRequest::GetTransactionCount;
|
||||
let request = test_request.build_request_json(1, None);
|
||||
@@ -244,7 +244,7 @@ mod tests {
|
||||
Ok(Value::Number(Number::from(50)))
|
||||
});
|
||||
// Failed request
|
||||
io.add_method("getLastId", |params: Params| {
|
||||
io.add_method("getRecentBlockHash", |params: Params| {
|
||||
if params != Params::None {
|
||||
Err(Error::invalid_request())
|
||||
} else {
|
||||
@@ -275,7 +275,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(balance.unwrap().as_u64().unwrap(), 50);
|
||||
|
||||
let block_hash = rpc_client.make_rpc_request(2, RpcRequest::GetLastId, None);
|
||||
let block_hash = rpc_client.make_rpc_request(2, RpcRequest::GetRecentBlockHash, None);
|
||||
assert_eq!(
|
||||
block_hash.unwrap().as_str().unwrap(),
|
||||
"deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"
|
||||
@@ -283,7 +283,7 @@ mod tests {
|
||||
|
||||
// Send erroneous parameter
|
||||
let block_hash =
|
||||
rpc_client.make_rpc_request(3, RpcRequest::GetLastId, Some(json!("paramter")));
|
||||
rpc_client.make_rpc_request(3, RpcRequest::GetRecentBlockHash, Some(json!("paramter")));
|
||||
assert_eq!(block_hash.is_err(), true);
|
||||
}
|
||||
|
||||
|
@@ -222,7 +222,7 @@ impl ThinClient {
|
||||
trace!("try_get_recent_block_hash send_to {}", &self.rpc_addr);
|
||||
let response = self
|
||||
.rpc_client
|
||||
.make_rpc_request(1, RpcRequest::GetLastId, None);
|
||||
.make_rpc_request(1, RpcRequest::GetRecentBlockHash, None);
|
||||
|
||||
match response {
|
||||
Ok(value) => {
|
||||
|
Reference in New Issue
Block a user