2023-07-21 04:21:49 +03:00
|
|
|
use super::TestApp;
|
2023-07-12 10:35:07 +03:00
|
|
|
use serde_json::json;
|
|
|
|
use tracing::{info, trace};
|
|
|
|
use web3_proxy::balance::Balance;
|
2023-07-06 08:18:39 +03:00
|
|
|
use web3_proxy::frontend::users::authentication::LoginPostResponse;
|
|
|
|
|
|
|
|
/// Helper function to get the user's balance
|
|
|
|
#[allow(unused)]
|
|
|
|
pub async fn user_get_balance(
|
|
|
|
x: &TestApp,
|
|
|
|
r: &reqwest::Client,
|
|
|
|
login_response: &LoginPostResponse,
|
2023-07-12 10:35:07 +03:00
|
|
|
) -> Balance {
|
2023-07-06 08:18:39 +03:00
|
|
|
let get_user_balance = format!("{}user/balance", x.proxy_provider.url());
|
2023-07-12 10:35:07 +03:00
|
|
|
|
2023-07-06 08:18:39 +03:00
|
|
|
let balance_response = r
|
|
|
|
.get(get_user_balance)
|
|
|
|
.bearer_auth(login_response.bearer_token)
|
|
|
|
.send()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2023-07-12 10:35:07 +03:00
|
|
|
trace!(
|
|
|
|
?balance_response,
|
|
|
|
"get balance for user #{}",
|
|
|
|
login_response.user.id
|
|
|
|
);
|
|
|
|
|
|
|
|
let balance = balance_response.json().await.unwrap();
|
2023-07-06 08:18:39 +03:00
|
|
|
|
2023-07-12 10:35:07 +03:00
|
|
|
info!("balance: {:#}", json!(&balance));
|
2023-07-06 08:18:39 +03:00
|
|
|
|
2023-07-12 10:35:07 +03:00
|
|
|
balance
|
2023-07-06 08:18:39 +03:00
|
|
|
}
|