Skip to content

Commit

Permalink
style: apply fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
antomor committed Oct 12, 2023
1 parent bfff9eb commit dcd53d8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
14 changes: 9 additions & 5 deletions core/bin/zksync_api/src/bin/dev_ticker_server.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
use actix_cors::Cors;
use actix_web::{middleware, App, HttpServer, web};
use actix_web::{middleware, web, App, HttpServer};
use providers::{
dev_liquidity_provider, dev_price_provider, proxy_liquidity_provider, proxy_price_provider, proxy_utils::ProxyState,
dev_liquidity_provider, dev_price_provider, proxy_liquidity_provider, proxy_price_provider,
proxy_utils::ProxyState,
};
use std::{
collections::HashMap,
fs::read_to_string,
path::{Path, PathBuf},
};
use structopt::StructOpt;
use tokio::sync::Mutex;
use zksync_config::ZkSyncConfig;
use zksync_types::{network::Network, TokenInfo};
use tokio::sync::Mutex;
use zksync_utils::parse_env;
use std::{collections::HashMap, fs::read_to_string, path::{Path, PathBuf}};

mod providers;

Expand All @@ -23,7 +28,6 @@ struct FeeTickerOpts {
sloppy: bool,
}


fn load_tokens(path: impl AsRef<Path>) -> Result<Vec<TokenInfo>, serde_json::Error> {
let mut full_path = parse_env::<PathBuf>("ZKSYNC_HOME");
full_path.push(path);
Expand Down
22 changes: 15 additions & 7 deletions core/bin/zksync_api/src/bin/providers/proxy_liquidity_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ pub(crate) fn config_liquidity_app() -> Scope {
web::scope("")
.service(web::resource("/asset_platforms").route(web::get().to(handle_get_asset_platforms)))
.service(
web::scope("/coins").service(web::scope("/{platform_id}").service(
web::scope("/contract").service(
web::resource("/{contract_address}").route(web::get().to(handle_get_coin_contract)),
web::scope("/coins").service(
web::scope("/{platform_id}").service(
web::scope("/contract").service(
web::resource("/{contract_address}")
.route(web::get().to(handle_get_coin_contract)),
),
),
)),
),
)
}

Expand Down Expand Up @@ -143,8 +146,13 @@ mod handle_get_coin_contract_tests {
market_data,
} = serde_json::from_str(&result).unwrap();

assert!(liquidity_score > 0.0, "Liquidity score is not greater than 0");
assert!(market_data.total_volume.usd.is_some() && market_data.total_volume.usd.unwrap() > 0.0, "Total volume in USD is not greater than 0");

assert!(
liquidity_score > 0.0,
"Liquidity score is not greater than 0"
);
assert!(
market_data.total_volume.usd.is_some() && market_data.total_volume.usd.unwrap() > 0.0,
"Total volume in USD is not greater than 0"
);
}
}
8 changes: 2 additions & 6 deletions core/bin/zksync_api/src/bin/providers/proxy_price_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,15 @@ mod fetch_market_chart_tests {
let response = test::call_service(&test_app, req).await;
println!("{:?}", response);
assert!(response.status().is_success());

let body = response.into_body();
let bytes = actix_web::body::to_bytes(body).await.unwrap();
let result = String::from_utf8(bytes.to_vec()).unwrap();

let CoinGeckoMarketChart {
prices,
} = serde_json::from_str(&result).unwrap();
let CoinGeckoMarketChart { prices } = serde_json::from_str(&result).unwrap();

assert!(!prices.is_empty(), "No prices returned");
}


}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion core/bin/zksync_api/src/bin/providers/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ impl Default for FakeHttpClient {
}

impl FakeHttpClient {

pub(crate) fn was_called(&self) -> bool {
self.called.load(Ordering::Relaxed)
}
Expand Down
3 changes: 1 addition & 2 deletions core/bin/zksync_api/src/fee_ticker/validator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub struct CoinsListItem {
pub platforms: Option<HashMap<String, Option<String>>>,
}


#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CoinGeckoTokenPrice(
pub i64, // timestamp (milliseconds)
Expand All @@ -50,4 +49,4 @@ pub struct CoinGeckoTokenPrice(
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CoinGeckoMarketChart {
pub prices: Vec<CoinGeckoTokenPrice>,
}
}

0 comments on commit dcd53d8

Please sign in to comment.