Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
garyyu committed Feb 13, 2019
1 parent 6cb78e7 commit 13e73e9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions chain/tests/test_txhashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use std::sync::Arc;
use crate::chain::store::ChainStore;
use crate::chain::txhashset;
use crate::core::core::BlockHeader;
use grin_core::core::hash::Hashed;
use crate::util::file;
use grin_core::core::hash::Hashed;

fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);
Expand All @@ -45,21 +45,31 @@ fn test_unexpected_zip() {
let head = BlockHeader::default();
// First check if everything works out of the box
assert!(txhashset::zip_read(db_root.clone(), &head).is_ok());
let zip_path = Path::new(&db_root).join(format!("txhashset_snapshot_{}.zip", head.hash().to_string()));
let zip_path = Path::new(&db_root).join(format!(
"txhashset_snapshot_{}.zip",
head.hash().to_string()
));
let zip_file = File::open(&zip_path).unwrap();
assert!(txhashset::zip_write(db_root.clone(), zip_file, &head).is_ok());
// Remove temp txhashset dir
assert!(fs::remove_dir_all(Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()))).is_err());
assert!(fs::remove_dir_all(
Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()))
)
.is_err());
// Then add strange files in the original txhashset folder
write_file(db_root.clone());
assert!(txhashset::zip_read(db_root.clone(), &head).is_ok());
// Check that the temp dir dos not contains the strange files
let txhashset_zip_path = Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()));
let txhashset_zip_path =
Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()));
assert!(txhashset_contains_expected_files(
format!("txhashset_zip_{}", head.hash().to_string()),
txhashset_zip_path.clone()
));
assert!(fs::remove_dir_all(Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()))).is_err());
assert!(fs::remove_dir_all(
Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string()))
)
.is_err());

let zip_file = File::open(zip_path).unwrap();
assert!(txhashset::zip_write(db_root.clone(), zip_file, &head).is_ok());
Expand Down

0 comments on commit 13e73e9

Please sign in to comment.