Skip to content

Commit 0d0b61c

Browse files
committed
add signer sample config parsing test
1 parent 6f7000a commit 0d0b61c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

stacks-signer/src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,28 @@ chain_id = {chain_id}
824824
mod tests {
825825
use super::*;
826826

827+
#[test]
828+
fn test_example_confs() {
829+
// Validate that all sample signer config files in sample/conf/signer/ parse as valid TOML.
830+
// Uses RawConfigFile (not GlobalConfig) since reference configs have placeholder values.
831+
let conf_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../sample/conf/signer");
832+
println!("Reading signer config files from: {conf_dir:?}");
833+
let conf_files = fs::read_dir(&conf_dir).unwrap();
834+
835+
for entry in conf_files {
836+
let entry = entry.unwrap();
837+
let path = entry.path();
838+
if path.is_file() {
839+
let file_name = path.file_name().unwrap().to_str().unwrap();
840+
if file_name.ends_with(".toml") {
841+
let data = fs::read_to_string(&path).unwrap();
842+
RawConfigFile::load_from_str(&data)
843+
.unwrap_or_else(|e| panic!("Failed to parse {file_name}: {e}"));
844+
}
845+
}
846+
}
847+
}
848+
827849
#[test]
828850
fn build_signer_config_tomls_should_produce_deserializable_strings() {
829851
let pk = StacksPrivateKey::from_hex(

0 commit comments

Comments
 (0)