Skip to content

Commit

Permalink
reduce visibility on TestRpc
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverNChalk committed Aug 25, 2024
1 parent b0c99b3 commit aa01bf5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use tokio::runtime::Runtime;

use crate::utils::{read_json, read_json_gz, WriteOnDrop};

pub fn test_data_path() -> PathBuf {
fn test_data_path() -> PathBuf {
std::env::var("TEST_DATA")
.unwrap_or_else(|err| panic!("Failed to load `TEST_DATA` env; err={err}"))
.parse()
.unwrap_or_else(|err| panic!("Failed to parse `TEST_DATA` env; err={err}"))
}

pub fn test_static_data_path() -> PathBuf {
fn test_static_data_path() -> PathBuf {
test_data_path().join("static.json")
}

Expand All @@ -32,7 +32,7 @@ pub fn get_static_cache() -> &'static RpcCache {
STATIC_CACHE.get_or_init(|| read_json(&test_static_data_path()))
}

pub struct TestRpc {
pub(crate) struct TestRpc {
static_cache: &'static RpcCache,
cache: RwLock<WriteOnDrop<RpcCache>>,
/// If the RPC is set the cache file will be ignored & overwritten.
Expand All @@ -48,7 +48,7 @@ impl TestRpc {
}

impl TestRpc {
pub fn load_snapshot(slot: u64) -> Self {
pub(crate) fn load_snapshot(slot: u64) -> Self {
let static_cache = get_static_cache();
let cache_path = test_data_path().join(format!("snapshots/{slot}.json.gz"));
let cache =
Expand All @@ -57,7 +57,7 @@ impl TestRpc {
TestRpc { static_cache, cache, rpc: None }
}

pub fn load_scenario(name: &str) -> Self {
pub(crate) fn load_scenario(name: &str) -> Self {
let cache_path = test_data_path().join(format!("{name}.json.gz"));

let rpc = match std::env::var("TEST_RPC") {
Expand Down Expand Up @@ -114,7 +114,6 @@ impl TestRpc {
}
}

// TODO: Serialize `Account` better.
#[serde_as]
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct RpcCache(
Expand Down

0 comments on commit aa01bf5

Please sign in to comment.