Skip to content

Commit

Permalink
update parse url and timestamp tests (#157)
Browse files Browse the repository at this point in the history
* update parse url and timestamp tests

* format
  • Loading branch information
sslivkoff authored Dec 27, 2023
1 parent 50d4dfc commit 24181bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions crates/cli/src/parse/source.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use std::env;

use crate::args::Args;
use cryo_freeze::{Fetcher, ParseError, Source, SourceLabels};
use ethers::prelude::*;
use governor::{Quota, RateLimiter};
use polars::prelude::*;
use std::num::NonZeroU32;

use cryo_freeze::{Fetcher, ParseError, Source, SourceLabels};

use crate::args::Args;

pub(crate) async fn parse_source(args: &Args) -> Result<Source, ParseError> {
// parse network info
let rpc_url = parse_rpc_url(args);
let rpc_url = parse_rpc_url(args)?;
let provider =
Provider::<RetryClient<Http>>::new_client(&rpc_url, args.max_retries, args.initial_backoff)
.map_err(|_e| ParseError::ParseError("could not connect to provider".to_string()))?;
Expand Down Expand Up @@ -57,7 +55,7 @@ pub(crate) async fn parse_source(args: &Args) -> Result<Source, ParseError> {
Ok(output)
}

fn parse_rpc_url(args: &Args) -> String {
pub(crate) fn parse_rpc_url(args: &Args) -> Result<String, ParseError> {
let mut url = match &args.rpc {
Some(url) => url.clone(),
_ => match env::var("ETH_RPC_URL") {
Expand All @@ -71,5 +69,5 @@ fn parse_rpc_url(args: &Args) -> String {
if !url.starts_with("http") {
url = "http://".to_string() + url.as_str();
};
url
Ok(url)
}
2 changes: 1 addition & 1 deletion crates/cli/src/parse/timestamps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ mod tests {
use super::*;

async fn setup_fetcher() -> Fetcher<RetryClient<Http>> {
let rpc_url = String::from("https://eth.merkle.io");
let rpc_url = crate::parse::source::parse_rpc_url(&Args::default()).unwrap();
let max_retry = 5;
let initial_backoff = 500;
let max_concurrent_requests = 100;
Expand Down

0 comments on commit 24181bb

Please sign in to comment.