test logs
This commit is contained in:
parent
38b266156a
commit
94d0a25aaf
39
Cargo.lock
generated
39
Cargo.lock
generated
@ -4752,32 +4752,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rstest"
|
|
||||||
version = "0.17.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "de1bb486a691878cd320c2f0d319ba91eeaa2e894066d8b5f8f117c000e9d962"
|
|
||||||
dependencies = [
|
|
||||||
"futures",
|
|
||||||
"futures-timer",
|
|
||||||
"rstest_macros",
|
|
||||||
"rustc_version",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rstest_macros"
|
|
||||||
version = "0.17.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "290ca1a1c8ca7edb7c3283bd44dc35dd54fdec6253a3912e201ba1072018fca8"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"rustc_version",
|
|
||||||
"syn 1.0.109",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_decimal"
|
name = "rust_decimal"
|
||||||
version = "1.30.0"
|
version = "1.30.0"
|
||||||
@ -5991,6 +5965,17 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-log"
|
||||||
|
version = "0.2.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9601d162c1d77e62c1ea0bc8116cd1caf143ce3af947536c3c9052a1677fe0c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
@ -6974,7 +6959,6 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rmp-serde",
|
"rmp-serde",
|
||||||
"rstest",
|
|
||||||
"rust_decimal",
|
"rust_decimal",
|
||||||
"sentry",
|
"sentry",
|
||||||
"sentry-tracing",
|
"sentry-tracing",
|
||||||
@ -6983,6 +6967,7 @@ dependencies = [
|
|||||||
"serde_prometheus",
|
"serde_prometheus",
|
||||||
"siwe",
|
"siwe",
|
||||||
"strum 0.25.0",
|
"strum 0.25.0",
|
||||||
|
"test-log",
|
||||||
"time 0.3.22",
|
"time 0.3.22",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-console",
|
"tokio-console",
|
||||||
|
@ -51,9 +51,4 @@ mod tests {
|
|||||||
assert!(x.get(&1).is_some());
|
assert!(x.get(&1).is_some());
|
||||||
assert!(x.get(&0).is_none());
|
assert!(x.get(&0).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[tokio::test(start_paused = true)]
|
|
||||||
// async fn test_overweight() {
|
|
||||||
// todo!("wip");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -105,5 +105,7 @@ url = { version = "2.4.0", features = ["serde"] }
|
|||||||
uuid = { version = "1.3.4", default-features = false, features = ["fast-rng", "serde", "v4", "zerocopy"] }
|
uuid = { version = "1.3.4", default-features = false, features = ["fast-rng", "serde", "v4", "zerocopy"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rstest = "0.17.0"
|
test-log = { version = "0.2.12", default-features = false, features = ["trace"] }
|
||||||
tokio = { version = "1.28.2", features = ["full", "test-util"] }
|
tokio = { version = "1.28.2", features = ["full", "test-util"] }
|
||||||
|
tracing = {version = "0.1", default-features = false}
|
||||||
|
tracing-subscriber = {version = "0.3", default-features = false, features = ["env-filter", "fmt"]}
|
||||||
|
@ -258,6 +258,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
use web3_proxy::{
|
use web3_proxy::{
|
||||||
config::{AppConfig, Web3RpcConfig},
|
config::{AppConfig, Web3RpcConfig},
|
||||||
@ -266,26 +267,17 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[tokio::test]
|
#[test_log::test(tokio::test)]
|
||||||
async fn it_works() {
|
async fn it_works() {
|
||||||
// TODO: move basic setup into a test fixture
|
// TODO: move basic setup into a test fixture
|
||||||
let path = env::var("PATH").unwrap();
|
let path = env::var("PATH").unwrap();
|
||||||
|
|
||||||
println!("path: {}", path);
|
info!("path: {}", path);
|
||||||
|
|
||||||
// TODO: how should we handle logs in this?
|
|
||||||
// TODO: option for super verbose logs
|
|
||||||
std::env::set_var(
|
|
||||||
"RUST_LOG",
|
|
||||||
"info,ethers_providers::rpc=off,web3_proxy=debug",
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: how should we do test logging setup with tracing?
|
|
||||||
// let _ = env_logger::builder().is_test(true).try_init();
|
|
||||||
|
|
||||||
|
// todo: fork polygon so we can test our payment contracts
|
||||||
let anvil = Anvil::new().spawn();
|
let anvil = Anvil::new().spawn();
|
||||||
|
|
||||||
println!("Anvil running at `{}`", anvil.endpoint());
|
info!("Anvil running at `{}`", anvil.endpoint());
|
||||||
|
|
||||||
let anvil_provider = Provider::<Http>::try_from(anvil.endpoint()).unwrap();
|
let anvil_provider = Provider::<Http>::try_from(anvil.endpoint()).unwrap();
|
||||||
|
|
||||||
@ -306,8 +298,6 @@ mod tests {
|
|||||||
min_synced_rpcs: 1,
|
min_synced_rpcs: 1,
|
||||||
public_requests_per_period: Some(1_000_000),
|
public_requests_per_period: Some(1_000_000),
|
||||||
response_cache_max_bytes: 10_u64.pow(7),
|
response_cache_max_bytes: 10_u64.pow(7),
|
||||||
redirect_public_url: Some("example.com/".to_string()),
|
|
||||||
redirect_rpc_key_url: Some("example.com/{{rpc_key_id}}".to_string()),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
balanced_rpcs: HashMap::from([
|
balanced_rpcs: HashMap::from([
|
||||||
@ -328,6 +318,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
// TODO: i don't think "both" is working
|
||||||
"anvil_both".to_string(),
|
"anvil_both".to_string(),
|
||||||
Web3RpcConfig {
|
Web3RpcConfig {
|
||||||
http_url: Some(anvil.endpoint()),
|
http_url: Some(anvil.endpoint()),
|
||||||
@ -345,7 +336,7 @@ mod tests {
|
|||||||
|
|
||||||
// spawn another thread for running the app
|
// spawn another thread for running the app
|
||||||
// TODO: allow launching into the local tokio runtime instead of creating a new one?
|
// TODO: allow launching into the local tokio runtime instead of creating a new one?
|
||||||
let handle = {
|
let app_handle = {
|
||||||
let frontend_port = 0;
|
let frontend_port = 0;
|
||||||
let prometheus_port = 0;
|
let prometheus_port = 0;
|
||||||
let shutdown_sender = shutdown_sender.clone();
|
let shutdown_sender = shutdown_sender.clone();
|
||||||
@ -400,11 +391,12 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(first_block_num, second_block_num - 1);
|
assert_eq!(first_block_num, second_block_num - 1);
|
||||||
|
|
||||||
|
// TODO: how do we make fixtures run this at the end?
|
||||||
// tell the test app to shut down
|
// tell the test app to shut down
|
||||||
shutdown_sender.send(()).unwrap();
|
shutdown_sender.send(()).unwrap();
|
||||||
|
|
||||||
println!("waiting for shutdown...");
|
info!("waiting for shutdown...");
|
||||||
// TODO: panic if a timeout is reached
|
// TODO: panic if a timeout is reached
|
||||||
handle.await.unwrap().unwrap();
|
app_handle.await.unwrap().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1954,15 +1954,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[test_log::test(tokio::test)]
|
||||||
async fn test_all_connections() {
|
async fn test_all_connections() {
|
||||||
// // TODO: how should we do test logging setup with tracing?
|
|
||||||
// let _ = env_logger::builder()
|
|
||||||
// .filter_level(LevelFilter::Error)
|
|
||||||
// .filter_module("web3_proxy", LevelFilter::Trace)
|
|
||||||
// .is_test(true)
|
|
||||||
// .try_init();
|
|
||||||
|
|
||||||
// TODO: use chrono, not SystemTime
|
// TODO: use chrono, not SystemTime
|
||||||
let now: U256 = SystemTime::now()
|
let now: U256 = SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
|
Loading…
Reference in New Issue
Block a user