diff --git a/web3_proxy/tests/common/create_admin.rs b/web3_proxy/tests/common/create_admin.rs index d00baa81..8039a052 100644 --- a/web3_proxy/tests/common/create_admin.rs +++ b/web3_proxy/tests/common/create_admin.rs @@ -25,7 +25,13 @@ pub async fn create_user_as_admin( x.proxy_provider.url(), admin_wallet.address() ); - let admin_login_message = r.get(admin_login_get_url).send().await.unwrap(); + let admin_login_message = r + .get(admin_login_get_url) + .send() + .await + .unwrap() + .error_for_status() + .unwrap(); let admin_login_message = admin_login_message.text().await.unwrap(); // Sign the message and POST it to login as admin @@ -80,7 +86,9 @@ pub async fn create_user_as_admin( x.proxy_provider.url(), admin_wallet.address() ); - let admin_login_message = r.get(admin_login_get_url).send().await.unwrap(); + let admin_login_message = r.get(admin_login_get_url).send().await.unwrap() + .error_for_status() + .unwrap(); assert_eq!(admin_login_message.status(), StatusCode::OK); diff --git a/web3_proxy/tests/common/create_user.rs b/web3_proxy/tests/common/create_user.rs index 4f82d975..d7a0f605 100644 --- a/web3_proxy/tests/common/create_user.rs +++ b/web3_proxy/tests/common/create_user.rs @@ -25,7 +25,13 @@ pub async fn create_user( x.proxy_provider.url(), user_wallet.address() ); - let user_login_message = r.get(user_login_get_url).send().await.unwrap(); + let user_login_message = r + .get(user_login_get_url) + .send() + .await + .unwrap() + .error_for_status() + .unwrap(); let user_login_message = user_login_message.text().await.unwrap(); // Sign the message and POST it to login as the user diff --git a/web3_proxy/tests/common/referral.rs b/web3_proxy/tests/common/referral.rs index 0779ba60..dc1d5ac3 100644 --- a/web3_proxy/tests/common/referral.rs +++ b/web3_proxy/tests/common/referral.rs @@ -55,6 +55,8 @@ pub async fn get_referral_code( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!(?referral_link); let referral_link = referral_link.json::().await.unwrap(); @@ -80,6 +82,8 @@ pub async fn get_shared_referral_codes( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!(?shared_referral_codes); @@ -109,6 +113,8 @@ pub async fn get_used_referral_codes( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!(?used_referral_codes); diff --git a/web3_proxy/tests/common/rpc_key.rs b/web3_proxy/tests/common/rpc_key.rs index d9c4f296..1367efae 100644 --- a/web3_proxy/tests/common/rpc_key.rs +++ b/web3_proxy/tests/common/rpc_key.rs @@ -47,6 +47,8 @@ pub async fn user_get_first_rpc_key( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!(?rpc_key_response); diff --git a/web3_proxy/tests/common/stats_accounting.rs b/web3_proxy/tests/common/stats_accounting.rs index b965422b..ab437539 100644 --- a/web3_proxy/tests/common/stats_accounting.rs +++ b/web3_proxy/tests/common/stats_accounting.rs @@ -20,6 +20,8 @@ pub async fn user_get_mysql_stats( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); trace!( ?_stats_response, @@ -46,6 +48,8 @@ pub async fn user_get_influx_stats_detailed( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!( ?_stats_response, @@ -88,6 +92,8 @@ pub async fn user_get_influx_stats_aggregated( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); info!( ?_stats_response, diff --git a/web3_proxy/tests/common/user_balance.rs b/web3_proxy/tests/common/user_balance.rs index bdba47b7..0ebe3377 100644 --- a/web3_proxy/tests/common/user_balance.rs +++ b/web3_proxy/tests/common/user_balance.rs @@ -18,6 +18,8 @@ pub async fn user_get_balance( .bearer_auth(login_response.bearer_token) .send() .await + .unwrap() + .error_for_status() .unwrap(); trace!( ?balance_response, diff --git a/web3_proxy/tests/test_sum_credits_used.rs b/web3_proxy/tests/test_sum_credits_used.rs index 30508ee1..9cebcbab 100644 --- a/web3_proxy/tests/test_sum_credits_used.rs +++ b/web3_proxy/tests/test_sum_credits_used.rs @@ -11,6 +11,7 @@ use crate::common::{ use ethers::prelude::U64; use migration::sea_orm::prelude::Decimal; use std::time::Duration; +use tokio::time::sleep; use tracing::info; use web3_proxy::balance::Balance; @@ -91,9 +92,16 @@ async fn test_sum_credits_used() { let cached_query_cost: Decimal = query_cost * cache_multipler; // flush stats + let _ = x.flush_stats().await.unwrap(); + // due to intervals, we can't be sure this is true. it should be <= + // assert_eq!(flushed.relational, 2, "relational"); + // assert_eq!(flushed.timeseries, 1, "timeseries"); + + sleep(Duration::from_secs(1)).await; + let flushed = x.flush_stats().await.unwrap(); - assert_eq!(flushed.relational, 2, "relational"); - assert_eq!(flushed.timeseries, 1, "timeseries"); + assert_eq!(flushed.relational, 0, "relational"); + assert_eq!(flushed.timeseries, 0, "timeseries"); // TODO: sleep and then flush and make sure no more arrive