Skip to content

Commit

Permalink
add: test that the example configs can be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
0xB10C committed Dec 23, 2023
1 parent 22c6172 commit 3eb973e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions daemon-config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions shared/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,27 @@ impl From<log::ParseLevelError> 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
));
}
}

0 comments on commit 3eb973e

Please sign in to comment.