From f17dd5fa446f0a2b94544ba608dfe4f26e9ae97c Mon Sep 17 00:00:00 2001 From: eupn <36292692+eupn@users.noreply.github.com> Date: Sat, 25 May 2019 23:13:09 +0700 Subject: [PATCH] Fix warnings in tests (#2846) --- api/tests/rest.rs | 4 ++-- chain/tests/mine_simple_chain.rs | 5 ++--- chain/tests/test_coinbase_maturity.rs | 2 +- chain/tests/test_txhashset.rs | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/api/tests/rest.rs b/api/tests/rest.rs index 3651bf7172..4f583ab2b8 100644 --- a/api/tests/rest.rs +++ b/api/tests/rest.rs @@ -4,7 +4,7 @@ use grin_util as util; use crate::api::*; use hyper::{Body, Request, StatusCode}; 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::{thread, time}; @@ -27,7 +27,7 @@ pub struct CounterMiddleware { impl CounterMiddleware { fn new() -> CounterMiddleware { CounterMiddleware { - counter: ATOMIC_USIZE_INIT, + counter: AtomicUsize::new(0), } } diff --git a/chain/tests/mine_simple_chain.rs b/chain/tests/mine_simple_chain.rs index a0d31f5220..514e892c30 100644 --- a/chain/tests/mine_simple_chain.rs +++ b/chain/tests/mine_simple_chain.rs @@ -23,14 +23,13 @@ use self::core::libtx::{self, build, reward}; use self::core::pow::Difficulty; use self::core::{consensus, global, pow}; use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain}; -use self::util::{RwLock, StopState}; +use self::util::RwLock; use chrono::Duration; use grin_chain as chain; use grin_chain::{BlockStatus, ChainAdapter, Options}; use grin_core as core; use grin_keychain as keychain; use grin_util as util; -use std::cell::RefCell; use std::fs; use std::sync::Arc; @@ -224,7 +223,7 @@ fn mine_reorg() { let genesis = pow::mine_genesis_block().unwrap(); { // 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 chain = setup_with_status_adapter(DIR_NAME, genesis.clone(), adapter.clone()); diff --git a/chain/tests/test_coinbase_maturity.rs b/chain/tests/test_coinbase_maturity.rs index 540c6ef8df..54a5236c2c 100644 --- a/chain/tests/test_coinbase_maturity.rs +++ b/chain/tests/test_coinbase_maturity.rs @@ -20,7 +20,7 @@ use self::core::libtx::{self, build}; use self::core::pow::Difficulty; use self::core::{consensus, pow}; use self::keychain::{ExtKeychain, ExtKeychainPath, Keychain}; -use self::util::{RwLock, StopState}; +use self::util::RwLock; use chrono::Duration; use env_logger; use grin_chain as chain; diff --git a/chain/tests/test_txhashset.rs b/chain/tests/test_txhashset.rs index 41be8d9c66..b45ef737ae 100644 --- a/chain/tests/test_txhashset.rs +++ b/chain/tests/test_txhashset.rs @@ -51,7 +51,7 @@ fn test_unexpected_zip() { let zip_file = File::open(&zip_path).unwrap(); assert!(txhashset::zip_write(PathBuf::from(db_root.clone()), zip_file, &head).is_ok()); // 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())), ); // Then add strange files in the original txhashset folder @@ -64,7 +64,7 @@ fn test_unexpected_zip() { format!("txhashset_zip_{}", head.hash().to_string()), 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())), ); @@ -76,7 +76,7 @@ fn test_unexpected_zip() { "txhashset".to_string(), 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 clean_output_dir(&db_root);