add test for checking the example.toml
This commit is contained in:
parent
22fa5136a8
commit
8e3547bbd0
2
TODO.md
2
TODO.md
|
@ -232,9 +232,9 @@ These are roughly in order of completition
|
||||||
- [x] nullable rpc_key_id on revert log
|
- [x] nullable rpc_key_id on revert log
|
||||||
- [x] attach origin to revert_log
|
- [x] attach origin to revert_log
|
||||||
- opt-in origin logging
|
- opt-in origin logging
|
||||||
|
- [x] test that runs check_config against example.toml
|
||||||
- [-] add configurable size limits to all the Caches
|
- [-] add configurable size limits to all the Caches
|
||||||
- instead of configuring each cache with MB sizes, have one value for total memory footprint and then percentages for each cache
|
- instead of configuring each cache with MB sizes, have one value for total memory footprint and then percentages for each cache
|
||||||
- [ ] test that runs check_config against example.toml
|
|
||||||
- [ ] improve sorting servers by weight
|
- [ ] improve sorting servers by weight
|
||||||
- if the utilization is > 100%, increase weight by 1? maybe just add utilization to the weight?
|
- if the utilization is > 100%, increase weight by 1? maybe just add utilization to the weight?
|
||||||
- if utilization is > hard limit, add a lot to the weight
|
- if utilization is > hard limit, add a lot to the weight
|
||||||
|
|
|
@ -13,7 +13,7 @@ volatile_redis_max_connections = 300
|
||||||
volatile_redis_url = "redis://REDIS_DOMAIN:REDIS_PORT/"
|
volatile_redis_url = "redis://REDIS_DOMAIN:REDIS_PORT/"
|
||||||
|
|
||||||
redirect_public_url = "https://llamanodes.com/public-rpc"
|
redirect_public_url = "https://llamanodes.com/public-rpc"
|
||||||
redirect_user_url = "https://llamanodes.com/dashboard/keys?key={rpc_key_id}"
|
redirect_rpc_key_url = "https://llamanodes.com/dashboard/keys?key={rpc_key_id}"
|
||||||
|
|
||||||
sentry_url = "https://SENTRY_KEY_A.ingest.sentry.io/SENTRY_KEY_B"
|
sentry_url = "https://SENTRY_KEY_A.ingest.sentry.io/SENTRY_KEY_B"
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ pub struct CheckConfigSubCommand {
|
||||||
|
|
||||||
impl CheckConfigSubCommand {
|
impl CheckConfigSubCommand {
|
||||||
pub async fn main(self) -> anyhow::Result<()> {
|
pub async fn main(self) -> anyhow::Result<()> {
|
||||||
|
let mut num_errors = 0;
|
||||||
|
|
||||||
info!("Loading config @ {}", self.path);
|
info!("Loading config @ {}", self.path);
|
||||||
let top_config: String = fs::read_to_string(self.path)?;
|
let top_config: String = fs::read_to_string(self.path)?;
|
||||||
let top_config: TopConfig = toml::from_str(&top_config)?;
|
let top_config: TopConfig = toml::from_str(&top_config)?;
|
||||||
|
@ -72,11 +74,49 @@ impl CheckConfigSubCommand {
|
||||||
}
|
}
|
||||||
Some(x) => {
|
Some(x) => {
|
||||||
if !x.contains("{rpc_key_id}") {
|
if !x.contains("{rpc_key_id}") {
|
||||||
|
num_errors += 1;
|
||||||
error!("redirect_user_url user url must contain \"{{rpc_key_id}}\"")
|
error!("redirect_user_url user url must contain \"{{rpc_key_id}}\"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
// TODO: print num warnings and have a flag to fail even on warnings
|
||||||
|
|
||||||
|
if num_errors == 0 {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(anyhow::anyhow!(format!(
|
||||||
|
"there were {} errors!",
|
||||||
|
num_errors
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn check_example_toml() {
|
||||||
|
let path = env::current_dir().expect("path");
|
||||||
|
|
||||||
|
let parent = path.parent().expect("always a parent");
|
||||||
|
|
||||||
|
let config_path = parent.join("config").join("example.toml");
|
||||||
|
|
||||||
|
let config_path_str = config_path.to_str().expect("always a valid path");
|
||||||
|
|
||||||
|
let check_config_command =
|
||||||
|
CheckConfigSubCommand::from_args(&["check_config"], &[config_path_str])
|
||||||
|
.expect("the command should have run");
|
||||||
|
|
||||||
|
let check_config_result = check_config_command.main().await;
|
||||||
|
|
||||||
|
println!("{:?}", check_config_result);
|
||||||
|
|
||||||
|
check_config_result.expect("the config should pass all checks");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue