From ffc5a46dc4f4b171a7ed1734a4bf20fb0050ee66 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 29 Jun 2023 12:41:21 -0700 Subject: [PATCH] add some stub tests --- web3_proxy/tests/common/mod.rs | 5 +++-- web3_proxy/tests/test_admins.rs | 27 +++++++++++++++++++++++++++ web3_proxy/tests/test_proxy.rs | 3 ++- web3_proxy/tests/test_users.rs | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 web3_proxy/tests/test_admins.rs create mode 100644 web3_proxy/tests/test_users.rs diff --git a/web3_proxy/tests/common/mod.rs b/web3_proxy/tests/common/mod.rs index 6e0f4422..f6283255 100644 --- a/web3_proxy/tests/common/mod.rs +++ b/web3_proxy/tests/common/mod.rs @@ -58,7 +58,8 @@ impl TestApp { let anvil_provider = Provider::::try_from(anvil.endpoint()).unwrap(); // make a test TopConfig - // TODO: load TopConfig from a file? CliConfig could have `cli_config.load_top_config`. would need to inject our endpoint ports + // TODO: test influx + // TODO: test redis let top_config = TopConfig { app: AppConfig { chain_id: 31337, @@ -76,7 +77,7 @@ impl TestApp { ..Default::default() }, balanced_rpcs: HashMap::from([( - "anvil_both".to_string(), + "anvil".to_string(), Web3RpcConfig { http_url: Some(anvil.endpoint()), ws_url: Some(anvil.ws_endpoint()), diff --git a/web3_proxy/tests/test_admins.rs b/web3_proxy/tests/test_admins.rs new file mode 100644 index 00000000..1e211b8c --- /dev/null +++ b/web3_proxy/tests/test_admins.rs @@ -0,0 +1,27 @@ +mod common; + +use crate::common::TestApp; + +#[ignore] +#[test_log::test(tokio::test)] +async fn test_admin_imitate_user() { + let x = TestApp::spawn().await; + + todo!(); +} + +#[ignore] +#[test_log::test(tokio::test)] +async fn test_admin_grant_credits() { + let x = TestApp::spawn().await; + + todo!(); +} + +#[ignore] +#[test_log::test(tokio::test)] +async fn test_admin_change_user_tier() { + let x = TestApp::spawn().await; + + todo!(); +} diff --git a/web3_proxy/tests/test_proxy.rs b/web3_proxy/tests/test_proxy.rs index 4234502b..ca710d84 100644 --- a/web3_proxy/tests/test_proxy.rs +++ b/web3_proxy/tests/test_proxy.rs @@ -7,7 +7,7 @@ use tokio::time::{sleep, Instant}; use web3_proxy::rpcs::blockchain::ArcBlock; #[test_log::test(tokio::test)] -async fn it_works() { +async fn it_starts_and_stops() { let x = TestApp::spawn().await; let anvil_provider = &x.anvil_provider; @@ -65,5 +65,6 @@ async fn it_works() { assert_eq!(anvil_result, proxy_result.unwrap()); + // most tests won't need to wait, but we should wait here to be sure all the shutdown logic works properly x.wait().await; } diff --git a/web3_proxy/tests/test_users.rs b/web3_proxy/tests/test_users.rs new file mode 100644 index 00000000..9a76051c --- /dev/null +++ b/web3_proxy/tests/test_users.rs @@ -0,0 +1,19 @@ +mod common; + +use crate::common::TestApp; + +#[ignore] +#[test_log::test(tokio::test)] +async fn test_log_in_and_out() { + let x = TestApp::spawn().await; + + todo!(); +} + +#[ignore] +#[test_log::test(tokio::test)] +async fn test_referral_bonus() { + let x = TestApp::spawn().await; + + todo!(); +}