Refactor RPC tests (#23483)
This commit is contained in:
parent
36ad59673c
commit
38db1dead4
|
@ -33,7 +33,7 @@ pub type StringDecimals = String;
|
|||
pub const MAX_BASE58_BYTES: usize = 128;
|
||||
|
||||
/// A duplicate representation of an Account for pretty JSON serialization
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UiAccount {
|
||||
pub lamports: u64,
|
||||
|
|
|
@ -117,7 +117,7 @@ pub struct RpcInflationRate {
|
|||
pub epoch: Epoch,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcKeyedAccount {
|
||||
pub pubkey: String,
|
||||
|
@ -246,7 +246,7 @@ pub struct RpcBlockProductionRange {
|
|||
pub last_slot: Slot,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcBlockProduction {
|
||||
/// Map of leader base58 identity pubkeys to a tuple of `(number of leader slots, number of blocks produced)`
|
||||
|
@ -363,7 +363,7 @@ pub struct RpcAccountBalance {
|
|||
pub lamports: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcSupply {
|
||||
pub total: u64,
|
||||
|
|
2423
rpc/src/rpc.rs
2423
rpc/src/rpc.rs
File diff suppressed because it is too large
Load Diff
|
@ -808,7 +808,7 @@ mod tests {
|
|||
let expected: Response = serde_json::from_str(expected).unwrap();
|
||||
|
||||
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
assert_eq!(expected, result);
|
||||
assert_eq!(result, expected);
|
||||
|
||||
// Test bad parameter
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[1]}"#;
|
||||
|
@ -817,7 +817,7 @@ mod tests {
|
|||
let expected: Response = serde_json::from_str(expected).unwrap();
|
||||
|
||||
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
assert_eq!(expected, result);
|
||||
assert_eq!(result, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1071,7 +1071,7 @@ mod tests {
|
|||
let expected: Response = serde_json::from_str(expected).unwrap();
|
||||
|
||||
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
assert_eq!(expected, result);
|
||||
assert_eq!(result, expected);
|
||||
|
||||
// Test bad parameter
|
||||
let req = r#"{"jsonrpc":"2.0","id":1,"method":"accountUnsubscribe","params":[1]}"#;
|
||||
|
@ -1080,7 +1080,7 @@ mod tests {
|
|||
let expected: Response = serde_json::from_str(expected).unwrap();
|
||||
|
||||
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
|
||||
assert_eq!(expected, result);
|
||||
assert_eq!(result, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::Bank;
|
||||
use {super::Bank, solana_program_runtime::sysvar_cache::SysvarCache};
|
||||
|
||||
impl Bank {
|
||||
pub(crate) fn fill_missing_sysvar_cache_entries(&self) {
|
||||
|
@ -10,6 +10,10 @@ impl Bank {
|
|||
let mut sysvar_cache = self.sysvar_cache.write().unwrap();
|
||||
sysvar_cache.reset();
|
||||
}
|
||||
|
||||
pub fn get_sysvar_cache_for_tests(&self) -> SysvarCache {
|
||||
self.sysvar_cache.read().unwrap().clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue