Skip to content

Commit

Permalink
fix(homeserver): parsing testnet configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Nov 13, 2024
1 parent 8deda4e commit b29c384
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pubky-homeserver/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ impl Config {

return Ok(Config {
bootstrap: testnet_config.bootstrap,
port: testnet_config.port,
keypair: testnet_config.keypair,
..config
});
}
Expand Down Expand Up @@ -301,4 +303,35 @@ mod tests {
}
)
}

#[test]
fn parse_with_testnet_flag() {
let config = Config::try_from_str(
r#"
# Secret key (in hex) to generate the Homeserver's Keypair
secret_key = "0123000000000000000000000000000000000000000000000000000000000000"
# Domain to be published in Pkarr records for this server to be accessible by.
domain = "localhost"
# Port for the Homeserver to listen on.
port = 6287
# Storage directory Defaults to <System's Data Directory>
storage = "/homeserver"
testnet = true
bootstrap = ["foo", "bar"]
# event stream
default_list_limit = 500
max_list_limit = 10000
"#,
)
.unwrap();

assert_eq!(config.keypair, Keypair::from_secret_key(&[0; 32]));
assert_eq!(config.port, 15411);
assert_ne!(
config.bootstrap,
Some(vec!["foo".to_string(), "bar".to_string()])
);
}
}

0 comments on commit b29c384

Please sign in to comment.