improve tests

This commit is contained in:
Bryan Stitt 2023-08-01 12:09:24 -07:00
parent 7cd91af3a8
commit 79542c94ae
7 changed files with 43 additions and 5 deletions

View File

@ -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);

View File

@ -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

View File

@ -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::<serde_json::Value>().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);

View File

@ -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);

View File

@ -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,

View File

@ -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,

View File

@ -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