web3-proxy/web3_proxy/tests/test_admins.rs

72 lines
2.0 KiB
Rust
Raw Normal View History

2023-06-29 22:41:21 +03:00
mod common;
use std::str::FromStr;
use std::time::Duration;
use crate::common::admin_increases_balance::admin_increase_balance;
use crate::common::create_admin::create_user_as_admin;
use crate::common::create_user::create_user;
use crate::common::get_user_balance::user_get_balance;
2023-06-29 22:41:21 +03:00
use crate::common::TestApp;
2023-07-01 05:24:48 +03:00
use rust_decimal::Decimal;
use tracing::info;
2023-06-29 22:41:21 +03:00
2023-06-30 22:53:21 +03:00
// #[cfg_attr(not(feature = "tests-needing-docker"), ignore)]
#[ignore = "under construction"]
2023-06-29 22:41:21 +03:00
#[test_log::test(tokio::test)]
async fn test_admin_imitate_user() {
let x = TestApp::spawn(true).await;
2023-06-29 22:41:21 +03:00
todo!();
}
2023-07-01 05:24:48 +03:00
#[cfg_attr(not(feature = "tests-needing-docker"), ignore)]
2023-06-29 22:41:21 +03:00
#[test_log::test(tokio::test)]
async fn test_admin_grant_credits() {
2023-07-01 22:26:42 +03:00
info!("Starting admin grant credits test");
let x = TestApp::spawn(true).await;
let r = reqwest::Client::builder()
.timeout(Duration::from_secs(3))
.build()
.unwrap();
2023-06-29 22:41:21 +03:00
2023-07-01 05:24:48 +03:00
// Setup variables that will be used
let user_wallet = x.wallet(0);
2023-07-01 05:24:48 +03:00
let admin_wallet = x.wallet(1);
info!(?admin_wallet);
let user_login_response = create_user(&x, &r, &user_wallet, None).await;
let admin_login_response = create_user_as_admin(&x, &r, &admin_wallet).await;
2023-07-01 22:26:42 +03:00
info!(?admin_login_response);
2023-07-01 05:24:48 +03:00
let increase_balance_response = admin_increase_balance(
&x,
&r,
&admin_login_response,
&user_wallet,
Decimal::from(100),
)
.await;
2023-07-01 05:24:48 +03:00
assert_eq!(
Decimal::from_str(increase_balance_response["amount"].as_str().unwrap()).unwrap(),
Decimal::from(100)
2023-07-01 22:38:56 +03:00
);
let user_balance_response = user_get_balance(&x, &r, &user_login_response).await;
assert_eq!(
Decimal::from_str(user_balance_response["balance"].as_str().unwrap()).unwrap(),
Decimal::from(100)
);
x.wait().await;
2023-06-29 22:41:21 +03:00
}
2023-06-30 22:53:21 +03:00
// #[cfg_attr(not(feature = "tests-needing-docker"), ignore)]
#[ignore = "under construction"]
2023-06-29 22:41:21 +03:00
#[test_log::test(tokio::test)]
async fn test_admin_change_user_tier() {
let x = TestApp::spawn(true).await;
2023-06-29 22:41:21 +03:00
todo!();
}