From 3eb973ea373a70d287ff14e32f1324d5e11efcab Mon Sep 17 00:00:00 2001 From: 0xb10c Date: Sat, 23 Dec 2023 13:05:05 +0100 Subject: [PATCH] add: test that the example configs can be loaded --- daemon-config.toml.example | 4 ++-- shared/src/config.rs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/daemon-config.toml.example b/daemon-config.toml.example index fa40e0c..54578eb 100644 --- a/daemon-config.toml.example +++ b/daemon-config.toml.example @@ -22,8 +22,8 @@ rpc_port = 8332 # # RPC user and password # Generate with https://github.com/bitcoin/bitcoin/tree/master/share/rpcauth ! -# rpc_user = "" -# rpc_password = "" +rpc_user = "miningpoolobserver" +rpc_password = "" # Re-process all database transactions and apply new tags on deamon-startup. # This might be requried after an update. You don't need to run this everytime. diff --git a/shared/src/config.rs b/shared/src/config.rs index b60fd0e..1928d16 100644 --- a/shared/src/config.rs +++ b/shared/src/config.rs @@ -178,3 +178,27 @@ impl From for ConfigError { ConfigError::InvalidLogLevel(err) } } + +#[cfg(test)] +mod tests { + + #[test] + fn load_example_config() { + use crate::config; + use std::env; + + const EXAMPLE_DAEMON_CONFIG: &str = "../daemon-config.toml.example"; + env::set_var(config::ENVVAR_CONFIG_FILE, EXAMPLE_DAEMON_CONFIG); + let _cfg = config::load_daemon_config().expect(&format!( + "We should be able to load the deamon config file '{}'", + EXAMPLE_DAEMON_CONFIG + )); + + const EXAMPLE_WEB_CONFIG: &str = "../web-config.toml.example"; + env::set_var(config::ENVVAR_CONFIG_FILE, EXAMPLE_WEB_CONFIG); + let _cfg = config::load_web_config().expect(&format!( + "We should be able to load the web config file '{}'", + EXAMPLE_DAEMON_CONFIG + )); + } +}