WIP
This commit is contained in:
@@ -15,7 +15,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
serde_with = "3.8.1"
|
||||
sha256 = "1.5.0"
|
||||
tokio = { version = "1.37.0", features = ["time"] }
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
websockets = "0.3.0"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -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