diff --git a/eigentrust-cli/src/fs.rs b/eigentrust-cli/src/fs.rs index e81d7bea..63058ce3 100644 --- a/eigentrust-cli/src/fs.rs +++ b/eigentrust-cli/src/fs.rs @@ -118,3 +118,30 @@ pub fn load_config() -> Result { let filepath = get_file_path(CONFIG_FILE, FileType::Json)?; JSONFileStorage::::new(filepath).load() } + +#[cfg(test)] +mod tests { + use super::*; + use std::fs; + + #[test] + fn test_eigenfile_save_and_load() { + let test_data = vec![1u8, 2, 3, 4, 5]; + let eigen_file = EigenFile::KzgParams(999); + + eigen_file.save(test_data.clone()).unwrap(); + let loaded_data = eigen_file.load().unwrap(); + assert_eq!(test_data, loaded_data); + + fs::remove_file(eigen_file.path().unwrap()).unwrap(); + } + + #[test] + fn test_eigenfile_path_and_filename() { + let eigen_file = EigenFile::KzgParams(999); + let filename = eigen_file.filename(); + let path = eigen_file.path().unwrap(); + + assert!(path.to_string_lossy().contains(&filename)); + } +}