Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
add fs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brech1 committed Sep 20, 2023
1 parent 38459c1 commit ba94a6d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions eigentrust-cli/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,30 @@ pub fn load_config() -> Result<ClientConfig, EigenError> {
let filepath = get_file_path(CONFIG_FILE, FileType::Json)?;
JSONFileStorage::<ClientConfig>::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));
}
}

0 comments on commit ba94a6d

Please sign in to comment.