WIP
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
/// TODO: Eventually this will set up persistent keys on disk, as well
|
||||
/// as some configuration options for the Side Node, editable via a config file.
|
||||
pub(crate) fn init() {
|
||||
println!("Initializing Side Node")
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
pub(crate) fn init() -> Result<(), std::io::Error> {
|
||||
println!("Initializing Side Node");
|
||||
let key_path = Path::new("~/.side/node/keys.pem");
|
||||
|
||||
if let Some(parent_dir) = key_path.parent() {
|
||||
println!("Creating parent directory: {:?}", parent_dir);
|
||||
std::fs::create_dir_all(parent_dir)?;
|
||||
}
|
||||
|
||||
// let mut file = File::create(key_path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn creates_side_node_directory() {
|
||||
let node_dir = "~/.side/node";
|
||||
assert!(std::path::Path::new(node_dir).exists());
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn creates_stable_key_file() {
|
||||
// let keyfile = "~/.side/node/keys.pem";
|
||||
// assert!(std::path::Path::new(keyfile).exists());
|
||||
// }
|
||||
|
||||
// #[test]
|
||||
// fn creates_config_file() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user