Fix warnings in tests (#2846)

This commit is contained in:
eupn 2019-05-25 23:13:09 +07:00 committed by Antioch Peverell
parent a2a350dac7
commit f17dd5fa44
4 changed files with 8 additions and 9 deletions

View file

@ -4,7 +4,7 @@ use grin_util as util;
use crate::api::*; use crate::api::*;
use hyper::{Body, Request, StatusCode}; use hyper::{Body, Request, StatusCode};
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::{thread, time}; use std::{thread, time};
@ -27,7 +27,7 @@ pub struct CounterMiddleware {
impl CounterMiddleware { impl CounterMiddleware {
fn new() -> CounterMiddleware { fn new() -> CounterMiddleware {
CounterMiddleware { CounterMiddleware {
counter: ATOMIC_USIZE_INIT, counter: AtomicUsize::new(0),
} }
} }

View file

@ -23,14 +23,13 @@ use self::core::libtx::{self, build, reward};
use self::core::pow::Difficulty; use self::core::pow::Difficulty;
use self::core::{consensus, global, pow}; use self::core::{consensus, global, pow};
use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain}; use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use self::util::{RwLock, StopState}; use self::util::RwLock;
use chrono::Duration; use chrono::Duration;
use grin_chain as chain; use grin_chain as chain;
use grin_chain::{BlockStatus, ChainAdapter, Options}; use grin_chain::{BlockStatus, ChainAdapter, Options};
use grin_core as core; use grin_core as core;
use grin_keychain as keychain; use grin_keychain as keychain;
use grin_util as util; use grin_util as util;
use std::cell::RefCell;
use std::fs; use std::fs;
use std::sync::Arc; use std::sync::Arc;
@ -224,7 +223,7 @@ fn mine_reorg() {
let genesis = pow::mine_genesis_block().unwrap(); let genesis = pow::mine_genesis_block().unwrap();
{ {
// Create chain that reports last block status // Create chain that reports last block status
let mut last_status = RwLock::new(None); let last_status = RwLock::new(None);
let adapter = Arc::new(StatusAdapter::new(last_status)); let adapter = Arc::new(StatusAdapter::new(last_status));
let chain = setup_with_status_adapter(DIR_NAME, genesis.clone(), adapter.clone()); let chain = setup_with_status_adapter(DIR_NAME, genesis.clone(), adapter.clone());

View file

@ -20,7 +20,7 @@ use self::core::libtx::{self, build};
use self::core::pow::Difficulty; use self::core::pow::Difficulty;
use self::core::{consensus, pow}; use self::core::{consensus, pow};
use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain}; use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use self::util::{RwLock, StopState}; use self::util::RwLock;
use chrono::Duration; use chrono::Duration;
use env_logger; use env_logger;
use grin_chain as chain; use grin_chain as chain;

View file

@ -51,7 +51,7 @@ fn test_unexpected_zip() {
let zip_file = File::open(&zip_path).unwrap(); let zip_file = File::open(&zip_path).unwrap();
assert!(txhashset::zip_write(PathBuf::from(db_root.clone()), zip_file, &head).is_ok()); assert!(txhashset::zip_write(PathBuf::from(db_root.clone()), zip_file, &head).is_ok());
// Remove temp txhashset dir // Remove temp txhashset dir
fs::remove_dir_all( let _ = fs::remove_dir_all(
Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string())), Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string())),
); );
// Then add strange files in the original txhashset folder // Then add strange files in the original txhashset folder
@ -64,7 +64,7 @@ fn test_unexpected_zip() {
format!("txhashset_zip_{}", head.hash().to_string()), format!("txhashset_zip_{}", head.hash().to_string()),
txhashset_zip_path.clone() txhashset_zip_path.clone()
)); ));
fs::remove_dir_all( let _ = fs::remove_dir_all(
Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string())), Path::new(&db_root).join(format!("txhashset_zip_{}", head.hash().to_string())),
); );
@ -76,7 +76,7 @@ fn test_unexpected_zip() {
"txhashset".to_string(), "txhashset".to_string(),
txhashset_path.clone() txhashset_path.clone()
)); ));
fs::remove_dir_all(Path::new(&db_root).join("txhashset")); let _ = fs::remove_dir_all(Path::new(&db_root).join("txhashset"));
} }
// Cleanup chain directory // Cleanup chain directory
clean_output_dir(&db_root); clean_output_dir(&db_root);