diff --git a/Cargo.lock b/Cargo.lock index 7018772ff5..adbecf8700 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3800,20 +3800,9 @@ dependencies = [ [[package]] name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "num-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", @@ -4264,7 +4253,7 @@ dependencies = [ "md-5", "nom", "num-bigint-dig", - "num-derive 0.4.1", + "num-derive", "num-traits", "p256", "p384", @@ -6104,7 +6093,7 @@ dependencies = [ "diesel_migrations", "futures 0.3.29", "log", - "num-derive 0.3.3", + "num-derive", "num-traits", "prost", "rand", @@ -6158,7 +6147,7 @@ dependencies = [ "log-mdc", "monero", "newtype-ops", - "num-derive 0.3.3", + "num-derive", "num-format", "num-traits", "once_cell", diff --git a/applications/minotari_app_grpc/src/authentication/basic_auth.rs b/applications/minotari_app_grpc/src/authentication/basic_auth.rs index 20d23eb7fa..d1d148e21b 100644 --- a/applications/minotari_app_grpc/src/authentication/basic_auth.rs +++ b/applications/minotari_app_grpc/src/authentication/basic_auth.rs @@ -227,13 +227,9 @@ mod tests { } mod validate { - use std::{ - cmp::{max, min}, - thread::sleep, - }; + use std::{cmp::max, thread::sleep}; - use rand::RngCore; - use tari_utilities::{hex::Hex, ByteArray}; + use tari_utilities::hex::Hex; use super::*; use crate::authentication::salted_password::create_salted_hashed_password; diff --git a/applications/minotari_merge_mining_proxy/src/block_template_data.rs b/applications/minotari_merge_mining_proxy/src/block_template_data.rs index fa90b116e2..1ca1b94003 100644 --- a/applications/minotari_merge_mining_proxy/src/block_template_data.rs +++ b/applications/minotari_merge_mining_proxy/src/block_template_data.rs @@ -26,7 +26,7 @@ use std::{collections::HashMap, convert::TryFrom, sync::Arc}; #[cfg(not(test))] use chrono::Duration; -use chrono::{self, DateTime, Utc}; +use chrono::{DateTime, Utc}; use minotari_node_grpc_client::grpc; use tari_common_types::types::FixedHash; use tari_core::proof_of_work::monero_rx::FixedByteArray; diff --git a/applications/minotari_miner/src/stratum/controller.rs b/applications/minotari_miner/src/stratum/controller.rs index e569253b5e..24fe288151 100644 --- a/applications/minotari_miner/src/stratum/controller.rs +++ b/applications/minotari_miner/src/stratum/controller.rs @@ -21,7 +21,6 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // use std::{ - self, io::{BufRead, ErrorKind, Write}, sync::mpsc, thread, diff --git a/applications/minotari_miner/src/stratum/stratum_controller/controller.rs b/applications/minotari_miner/src/stratum/stratum_controller/controller.rs index 6abe804d5c..a9e8670b79 100644 --- a/applications/minotari_miner/src/stratum/stratum_controller/controller.rs +++ b/applications/minotari_miner/src/stratum/stratum_controller/controller.rs @@ -20,7 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -use std::{self, convert::TryFrom, sync::mpsc, thread, time::SystemTime}; +use std::{convert::TryFrom, sync::mpsc, thread, time::SystemTime}; use borsh::BorshDeserialize; use futures::stream::StreamExt; diff --git a/applications/minotari_miner/src/stratum/stream.rs b/applications/minotari_miner/src/stratum/stream.rs index 9ce8879055..aec0afa28d 100644 --- a/applications/minotari_miner/src/stratum/stream.rs +++ b/applications/minotari_miner/src/stratum/stream.rs @@ -21,7 +21,6 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // use std::{ - self, io::{self, BufRead, Read, Write}, net::TcpStream, }; diff --git a/base_layer/chat_ffi/src/contacts_liveness_data.rs b/base_layer/chat_ffi/src/contacts_liveness_data.rs index c1bb9b305a..45f98e87c9 100644 --- a/base_layer/chat_ffi/src/contacts_liveness_data.rs +++ b/base_layer/chat_ffi/src/contacts_liveness_data.rs @@ -147,8 +147,6 @@ pub unsafe extern "C" fn destroy_contacts_liveness_data(ptr: *mut ContactsLivene #[cfg(test)] mod test { - use std::convert::TryFrom; - use chrono::NaiveDateTime; use tari_contacts::contacts_service::service::{ContactMessageType, ContactOnlineStatus}; use tari_utilities::epoch_time::EpochTime; diff --git a/base_layer/chat_ffi/src/message.rs b/base_layer/chat_ffi/src/message.rs index 9be70ab11b..90cfea3436 100644 --- a/base_layer/chat_ffi/src/message.rs +++ b/base_layer/chat_ffi/src/message.rs @@ -427,13 +427,12 @@ pub unsafe extern "C" fn read_chat_message_id(message: *mut Message, error_out: #[cfg(test)] mod test { - use tari_contacts::contacts_service::types::{Direction, MessageBuilder}; + use tari_contacts::contacts_service::types::Direction; use tari_utilities::epoch_time::EpochTime; use super::*; use crate::{ byte_vector::{chat_byte_vector_destroy, chat_byte_vector_get_at, chat_byte_vector_get_length}, - message::read_chat_message_id, tari_address::destroy_tari_address, }; diff --git a/base_layer/chat_ffi/src/message_metadata.rs b/base_layer/chat_ffi/src/message_metadata.rs index c93d4a6398..b5a7b77611 100644 --- a/base_layer/chat_ffi/src/message_metadata.rs +++ b/base_layer/chat_ffi/src/message_metadata.rs @@ -169,20 +169,12 @@ pub unsafe extern "C" fn destroy_chat_message_metadata(ptr: *mut MessageMetadata #[cfg(test)] mod test { - use std::convert::TryFrom; - - use libc::c_uint; use tari_common_types::tari_address::TariAddress; use tari_contacts::contacts_service::types::MessageBuilder; use super::*; use crate::{ - byte_vector::{ - chat_byte_vector_create, - chat_byte_vector_destroy, - chat_byte_vector_get_at, - chat_byte_vector_get_length, - }, + byte_vector::{chat_byte_vector_destroy, chat_byte_vector_get_at, chat_byte_vector_get_length}, message::{chat_metadata_get_at, destroy_chat_message}, }; diff --git a/base_layer/common_types/src/encryption.rs b/base_layer/common_types/src/encryption.rs index 7de8e7bd90..68533e8ff0 100644 --- a/base_layer/common_types/src/encryption.rs +++ b/base_layer/common_types/src/encryption.rs @@ -109,11 +109,7 @@ pub fn encrypt_bytes_integral_nonce( #[cfg(test)] mod test { - use std::mem::size_of; - - use chacha20poly1305::{Key, KeyInit, Tag, XChaCha20Poly1305, XNonce}; - use rand::{rngs::OsRng, RngCore}; - use tari_utilities::{ByteArray, Hidden}; + use chacha20poly1305::{Key, KeyInit}; use super::*; diff --git a/base_layer/contacts/Cargo.toml b/base_layer/contacts/Cargo.toml index be609165fb..1b79725fc1 100644 --- a/base_layer/contacts/Cargo.toml +++ b/base_layer/contacts/Cargo.toml @@ -23,7 +23,7 @@ diesel = { version = "2.0.3", features = ["sqlite", "serde_json", "chrono", "64- diesel_migrations = "2.0.0" futures = { version = "^0.3.1", features = ["compat", "std"] } log = "0.4.6" -num-derive = "0.3.3" +num-derive = "0.4.2" num-traits = "0.2.15" prost = "0.11.9" rand = "0.8" diff --git a/base_layer/contacts/src/contacts_service/storage/sqlite_db.rs b/base_layer/contacts/src/contacts_service/storage/sqlite_db.rs index 40f9bf5e50..e3c4b1ad67 100644 --- a/base_layer/contacts/src/contacts_service/storage/sqlite_db.rs +++ b/base_layer/contacts/src/contacts_service/storage/sqlite_db.rs @@ -221,23 +221,16 @@ where TContactServiceDbConnection: PooledDbConnection) -> SyncPeer { diff --git a/base_layer/core/src/blocks/genesis_block.rs b/base_layer/core/src/blocks/genesis_block.rs index 42a18e2887..e428335ebb 100644 --- a/base_layer/core/src/blocks/genesis_block.rs +++ b/base_layer/core/src/blocks/genesis_block.rs @@ -401,8 +401,6 @@ mod test { use std::convert::TryFrom; use tari_common_types::{epoch::VnEpoch, types::Commitment}; - use tari_utilities::ByteArray; - use Network; use super::*; use crate::{ diff --git a/base_layer/core/src/chain_storage/blockchain_database.rs b/base_layer/core/src/chain_storage/blockchain_database.rs index f59ec29389..34c4566938 100644 --- a/base_layer/core/src/chain_storage/blockchain_database.rs +++ b/base_layer/core/src/chain_storage/blockchain_database.rs @@ -2512,7 +2512,6 @@ mod test { chain_strength_comparer::strongest_chain, consensus_constants::PowAlgorithmConstants, ConsensusConstantsBuilder, - ConsensusManager, }, proof_of_work::Difficulty, test_helpers::{ @@ -2816,7 +2815,6 @@ mod test { mod handle_possible_reorg { use super::*; - use crate::test_helpers::blockchain::update_block_and_smt; #[ignore] #[tokio::test] diff --git a/base_layer/core/src/common/limited_reader.rs b/base_layer/core/src/common/limited_reader.rs index a5c21fd76e..be80895a69 100644 --- a/base_layer/core/src/common/limited_reader.rs +++ b/base_layer/core/src/common/limited_reader.rs @@ -44,8 +44,6 @@ impl Read for LimitedBytesReader { #[cfg(test)] mod test { - use std::io::Read; - use super::*; impl LimitedBytesReader { diff --git a/base_layer/core/src/common/one_sided.rs b/base_layer/core/src/common/one_sided.rs index 3d5740ee08..cccbf37036 100644 --- a/base_layer/core/src/common/one_sided.rs +++ b/base_layer/core/src/common/one_sided.rs @@ -20,8 +20,6 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::result::Result; - use blake2::Blake2b; use digest::consts::U64; use tari_common_types::types::{PrivateKey, PublicKey, WalletHasher}; diff --git a/base_layer/core/src/consensus/consensus_encoding/hashing.rs b/base_layer/core/src/consensus/consensus_encoding/hashing.rs index 1eb42a460a..b3c4eacb91 100644 --- a/base_layer/core/src/consensus/consensus_encoding/hashing.rs +++ b/base_layer/core/src/consensus/consensus_encoding/hashing.rs @@ -71,7 +71,6 @@ impl Default for DomainSeparatedConsen mod tests { use blake2::Blake2b; use digest::consts::U32; - use tari_common::configuration::Network; use tari_crypto::hash_domain; use tari_script::script; diff --git a/base_layer/core/src/covenants/fields.rs b/base_layer/core/src/covenants/fields.rs index 480dd0a6b4..12e80b172d 100644 --- a/base_layer/core/src/covenants/fields.rs +++ b/base_layer/core/src/covenants/fields.rs @@ -565,9 +565,7 @@ mod test { use crate::transactions::key_manager::create_memory_db_key_manager; mod construct_challenge_from { - use blake2::Digest; use digest::Update; - use tari_crypto::hashing::DomainSeparation; use super::*; use crate::transactions::{tari_amount::MicroMinotari, transaction_components::RangeProofType}; @@ -618,11 +616,7 @@ mod test { mod get_field_value_ref { use super::*; - use crate::transactions::{ - key_manager::create_memory_db_key_manager, - tari_amount::MicroMinotari, - transaction_components::RangeProofType, - }; + use crate::transactions::{tari_amount::MicroMinotari, transaction_components::RangeProofType}; #[tokio::test] async fn it_retrieves_the_value_as_ref() { diff --git a/base_layer/core/src/proof_of_work/monero_rx/helpers.rs b/base_layer/core/src/proof_of_work/monero_rx/helpers.rs index dc4aea7399..e9c16e90fc 100644 --- a/base_layer/core/src/proof_of_work/monero_rx/helpers.rs +++ b/base_layer/core/src/proof_of_work/monero_rx/helpers.rs @@ -385,9 +385,8 @@ mod test { use borsh::BorshSerialize; use monero::{ - blockdata::transaction::{ExtraField, TxOutTarget}, + blockdata::transaction::TxOutTarget, consensus::deserialize, - cryptonote::hash::Hashable, util::ringct::{RctSig, RctSigBase, RctType}, Hash, PublicKey, @@ -397,7 +396,6 @@ mod test { TxOut, }; use tari_common::configuration::Network; - use tari_common_types::types::FixedHash; use tari_test_utils::unpack_enum; use tari_utilities::{ epoch_time::EpochTime, @@ -406,7 +404,7 @@ mod test { }; use super::*; - use crate::proof_of_work::{monero_rx::fixed_array::FixedByteArray, PowAlgorithm, ProofOfWork}; + use crate::proof_of_work::{PowAlgorithm, ProofOfWork}; // This tests checks the hash of monero-rs #[test] diff --git a/base_layer/core/src/proof_of_work/proof_of_work.rs b/base_layer/core/src/proof_of_work/proof_of_work.rs index 036a9be61e..963b0b6682 100644 --- a/base_layer/core/src/proof_of_work/proof_of_work.rs +++ b/base_layer/core/src/proof_of_work/proof_of_work.rs @@ -29,6 +29,7 @@ use tari_utilities::hex::Hex; use crate::proof_of_work::PowAlgorithm; +#[allow(dead_code)] pub trait AchievedDifficulty {} /// The proof of work data structure that is included in the block header. There's some non-Rustlike redundancy here diff --git a/base_layer/core/src/transactions/aggregated_body.rs b/base_layer/core/src/transactions/aggregated_body.rs index 47148fb116..203b43a3d7 100644 --- a/base_layer/core/src/transactions/aggregated_body.rs +++ b/base_layer/core/src/transactions/aggregated_body.rs @@ -429,7 +429,7 @@ impl Display for AggregateBody { #[cfg(test)] mod test { - use tari_common_types::types::{ComAndPubSignature, Commitment, FixedHash, PublicKey, Signature}; + use tari_common_types::types::{ComAndPubSignature, FixedHash, PublicKey, Signature}; use tari_script::{ExecutionStack, TariScript}; use super::*; diff --git a/base_layer/core/src/transactions/tari_amount.rs b/base_layer/core/src/transactions/tari_amount.rs index 4110f016fb..b48451aab5 100644 --- a/base_layer/core/src/transactions/tari_amount.rs +++ b/base_layer/core/src/transactions/tari_amount.rs @@ -395,8 +395,6 @@ impl DivAssign for Minotari { #[cfg(test)] mod test { - use std::{convert::TryFrom, str::FromStr}; - use super::*; #[test] diff --git a/base_layer/core/src/transactions/transaction_components/encrypted_data.rs b/base_layer/core/src/transactions/transaction_components/encrypted_data.rs index 273fd14740..c60b33e0ee 100644 --- a/base_layer/core/src/transactions/transaction_components/encrypted_data.rs +++ b/base_layer/core/src/transactions/transaction_components/encrypted_data.rs @@ -243,9 +243,8 @@ fn kdf_aead(encryption_key: &PrivateKey, commitment: &Commitment) -> EncryptedDa #[cfg(test)] mod test { - use rand::rngs::OsRng; - use tari_common_types::types::{CommitmentFactory, PrivateKey}; - use tari_crypto::{commitment::HomomorphicCommitmentFactory, keys::SecretKey}; + use tari_common_types::types::CommitmentFactory; + use tari_crypto::commitment::HomomorphicCommitmentFactory; use super::*; diff --git a/base_layer/core/src/transactions/transaction_components/test.rs b/base_layer/core/src/transactions/transaction_components/test.rs index 067ca86aef..3777128d7f 100644 --- a/base_layer/core/src/transactions/transaction_components/test.rs +++ b/base_layer/core/src/transactions/transaction_components/test.rs @@ -20,8 +20,8 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use rand::{self, rngs::OsRng}; -use tari_common_types::types::{ComAndPubSignature, PrivateKey, PublicKey, Signature}; +use rand::rngs::OsRng; +use tari_common_types::types::{PrivateKey, Signature}; use tari_crypto::{ commitment::HomomorphicCommitmentFactory, keys::SecretKey as SecretKeyTrait, @@ -42,10 +42,10 @@ use crate::{ create_memory_db_key_manager_with_range_proof_size, TransactionKeyManagerInterface, }, - tari_amount::{uT, MicroMinotari, T}, + tari_amount::{uT, T}, test_helpers, test_helpers::{TestParams, UtxoTestParams}, - transaction_components::{transaction_output::batch_verify_range_proofs, EncryptedData, OutputFeatures}, + transaction_components::{transaction_output::batch_verify_range_proofs, OutputFeatures}, transaction_protocol::TransactionProtocolError, CryptoFactories, }, @@ -567,16 +567,14 @@ async fn test_output_recover_openings() { mod validate_internal_consistency { - use blake2::Blake2b; - use digest::{consts::U32, Digest}; - use tari_common_types::types::FixedHash; + use digest::Digest; use tari_crypto::hashing::DomainSeparation; use super::*; use crate::{ covenants::{BaseLayerCovenantsDomain, COVENANTS_FIELD_HASHER_LABEL}, transactions::{ - key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}, + key_manager::MemoryDbKeyManager, test_helpers::{create_transaction_with, create_wallet_outputs}, }, }; diff --git a/base_layer/core/src/validation/block_body/test.rs b/base_layer/core/src/validation/block_body/test.rs index b1a706a521..bf47d4cce4 100644 --- a/base_layer/core/src/validation/block_body/test.rs +++ b/base_layer/core/src/validation/block_body/test.rs @@ -456,7 +456,6 @@ async fn it_rejects_zero_conf_double_spends() { mod body_only { use super::*; - use crate::validation::block_body::BlockBodyFullValidator; #[tokio::test] async fn it_rejects_invalid_input_metadata() { @@ -492,7 +491,7 @@ mod body_only { mod orphan_validator { use super::*; use crate::{ - transactions::transaction_components::{OutputType, RangeProofType}, + transactions::transaction_components::OutputType, txn_schema, validation::block_body::BlockBodyInternalConsistencyValidator, }; diff --git a/base_layer/key_manager/src/cipher_seed.rs b/base_layer/key_manager/src/cipher_seed.rs index acae2f54c1..642d655026 100644 --- a/base_layer/key_manager/src/cipher_seed.rs +++ b/base_layer/key_manager/src/cipher_seed.rs @@ -20,9 +20,8 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{convert::TryFrom, mem::size_of, str::FromStr}; +use std::{mem::size_of, str::FromStr}; -use argon2; use blake2::Blake2b; use chacha20::{ cipher::{NewCipher, StreamCipher}, diff --git a/base_layer/key_manager/src/key_manager.rs b/base_layer/key_manager/src/key_manager.rs index 0bac8d5995..fbd05508cc 100644 --- a/base_layer/key_manager/src/key_manager.rs +++ b/base_layer/key_manager/src/key_manager.rs @@ -174,7 +174,6 @@ where #[cfg(test)] mod test { use blake2::Blake2b; - use digest::consts::U64; use tari_crypto::ristretto::RistrettoPublicKey; use crate::key_manager::*; diff --git a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/imported_keys.rs b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/imported_keys.rs index 066bec86b8..2a2ad7fa03 100644 --- a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/imported_keys.rs +++ b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/imported_keys.rs @@ -21,7 +21,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use chacha20poly1305::XChaCha20Poly1305; use chrono::{NaiveDateTime, Utc}; -use diesel::{prelude::*, SqliteConnection}; +use diesel::prelude::*; use tari_common_types::encryption::{decrypt_bytes_integral_nonce, encrypt_bytes_integral_nonce}; use tari_crypto::keys::PublicKey; use tari_utilities::{hex::Hex, ByteArray, Hidden}; diff --git a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/key_manager_state.rs b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/key_manager_state.rs index 888744edb3..d83ff35394 100644 --- a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/key_manager_state.rs +++ b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/key_manager_state.rs @@ -20,11 +20,9 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::convert::TryFrom; - use chacha20poly1305::XChaCha20Poly1305; use chrono::{NaiveDateTime, Utc}; -use diesel::{prelude::*, SqliteConnection}; +use diesel::prelude::*; use tari_common_sqlite::util::diesel_ext::ExpectedRowsExtension; use tari_common_types::encryption::{decrypt_bytes_integral_nonce, encrypt_bytes_integral_nonce}; use tari_utilities::Hidden; diff --git a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/mod.rs b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/mod.rs index 4da82737fc..ed8249a627 100644 --- a/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/key_manager/src/key_manager_service/storage/sqlite_db/mod.rs @@ -20,10 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{ - convert::TryFrom, - sync::{Arc, RwLock}, -}; +use std::sync::{Arc, RwLock}; use chacha20poly1305::XChaCha20Poly1305; use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; @@ -259,14 +256,10 @@ where #[cfg(test)] mod test { - use std::convert::TryFrom; - use diesel::{sql_query, Connection, RunQueryDsl, SqliteConnection}; - use diesel_migrations::{EmbeddedMigrations, MigrationHarness}; use tempfile::tempdir; use super::*; - use crate::key_manager_service::storage::sqlite_db::{KeyManagerState, KeyManagerStateSql, NewKeyManagerStateSql}; #[test] fn test_key_manager_crud() { diff --git a/base_layer/key_manager/src/mnemonic.rs b/base_layer/key_manager/src/mnemonic.rs index eb99b57a1b..9a783bf5aa 100644 --- a/base_layer/key_manager/src/mnemonic.rs +++ b/base_layer/key_manager/src/mnemonic.rs @@ -282,7 +282,7 @@ pub trait Mnemonic { mod test { use std::str::FromStr; - use rand::{self, rngs::OsRng}; + use rand::rngs::OsRng; use tari_crypto::{keys::SecretKey, ristretto::RistrettoSecretKey, tari_utilities::byte_array::ByteArray}; use super::*; diff --git a/base_layer/mmr/src/merkle_mountain_range.rs b/base_layer/mmr/src/merkle_mountain_range.rs index 0eef7fee65..8aa3338ea1 100644 --- a/base_layer/mmr/src/merkle_mountain_range.rs +++ b/base_layer/mmr/src/merkle_mountain_range.rs @@ -23,7 +23,6 @@ use std::{ cmp::{max, min}, convert::TryInto, - iter::IntoIterator, marker::PhantomData, }; diff --git a/base_layer/mmr/src/sparse_merkle_tree/bit_utils.rs b/base_layer/mmr/src/sparse_merkle_tree/bit_utils.rs index d5b8bbc5ff..0aa5ed472c 100644 --- a/base_layer/mmr/src/sparse_merkle_tree/bit_utils.rs +++ b/base_layer/mmr/src/sparse_merkle_tree/bit_utils.rs @@ -99,7 +99,6 @@ pub fn traverse_direction( #[cfg(test)] mod test { use super::*; - use crate::sparse_merkle_tree::{bit_utils::count_common_prefix, NodeKey}; #[test] fn test_common_prefix() { diff --git a/base_layer/mmr/src/sparse_merkle_tree/node.rs b/base_layer/mmr/src/sparse_merkle_tree/node.rs index 6ac8be86c8..6d17a1426f 100644 --- a/base_layer/mmr/src/sparse_merkle_tree/node.rs +++ b/base_layer/mmr/src/sparse_merkle_tree/node.rs @@ -510,8 +510,7 @@ impl> BranchNode { #[cfg(test)] mod test { use blake2::Blake2b; - use digest::consts::U32; - use rand::{self, RngCore}; + use rand::RngCore; use super::*; use crate::sparse_merkle_tree::bit_utils::TraverseDirection::{Left, Right}; diff --git a/base_layer/mmr/src/sparse_merkle_tree/proofs.rs b/base_layer/mmr/src/sparse_merkle_tree/proofs.rs index cf7b3405fe..8cea6ddc61 100644 --- a/base_layer/mmr/src/sparse_merkle_tree/proofs.rs +++ b/base_layer/mmr/src/sparse_merkle_tree/proofs.rs @@ -227,7 +227,6 @@ impl> MerkleProofDigest for ExclusionProof { #[cfg(test)] mod test { use blake2::Blake2b; - use digest::consts::U32; use super::*; diff --git a/base_layer/mmr/tests/tests/with_blake512_hash.rs b/base_layer/mmr/tests/tests/with_blake512_hash.rs index 48488cf080..393ee30544 100644 --- a/base_layer/mmr/tests/tests/with_blake512_hash.rs +++ b/base_layer/mmr/tests/tests/with_blake512_hash.rs @@ -20,8 +20,6 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::string::ToString; - use blake2::Blake2b; use digest::consts::U64; use tari_crypto::{hash_domain, hashing::DomainSeparatedHasher}; diff --git a/base_layer/p2p/src/auto_update/mod.rs b/base_layer/p2p/src/auto_update/mod.rs index 97c28a4acb..dc9e52614e 100644 --- a/base_layer/p2p/src/auto_update/mod.rs +++ b/base_layer/p2p/src/auto_update/mod.rs @@ -213,7 +213,6 @@ fn maintainers() -> impl Iterator { #[cfg(test)] mod test { - use config; use tari_common::DefaultConfigLoader; use super::*; diff --git a/base_layer/p2p/src/comms_connector/inbound_connector.rs b/base_layer/p2p/src/comms_connector/inbound_connector.rs index bc31992d93..e56367c499 100644 --- a/base_layer/p2p/src/comms_connector/inbound_connector.rs +++ b/base_layer/p2p/src/comms_connector/inbound_connector.rs @@ -110,8 +110,6 @@ impl InboundDomainConnector { mod test { use futures::executor::block_on; use tari_comms::{message::MessageExt, wrap_in_envelope_body}; - use tari_comms_dht::domain_message::MessageHeader; - use tokio::sync::mpsc; use tower::ServiceExt; use super::*; diff --git a/base_layer/p2p/src/dns/client.rs b/base_layer/p2p/src/dns/client.rs index cd889fd034..50e4a61829 100644 --- a/base_layer/p2p/src/dns/client.rs +++ b/base_layer/p2p/src/dns/client.rs @@ -204,13 +204,7 @@ fn default_client_config() -> Arc { #[cfg(test)] mod mock { - use std::sync::Arc; - - use tari_shutdown::Shutdown; - use trust_dns_client::proto::error::ProtoError; - use super::*; - use crate::dns::mock::{DefaultOnSend, MockClientHandle}; impl Client> { pub async fn connect_mock(messages: Vec>) -> Result { diff --git a/base_layer/p2p/src/dns/mock.rs b/base_layer/p2p/src/dns/mock.rs index e4ee81a4a7..953f10e653 100644 --- a/base_layer/p2p/src/dns/mock.rs +++ b/base_layer/p2p/src/dns/mock.rs @@ -87,6 +87,7 @@ pub fn message(query: Query, answers: Vec, name_servers: Vec, ad } pub trait OnSend: Clone + Send + Sync + 'static { + #[allow(dead_code)] fn on_send( &mut self, response: Result, diff --git a/base_layer/p2p/src/domain_message.rs b/base_layer/p2p/src/domain_message.rs index 4217fb5de9..60a7b151a0 100644 --- a/base_layer/p2p/src/domain_message.rs +++ b/base_layer/p2p/src/domain_message.rs @@ -20,7 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::convert::{From, TryFrom}; +use std::convert::TryFrom; use tari_comms::{peer_manager::Peer, types::CommsPublicKey}; use tari_comms_dht::envelope::DhtMessageHeader; diff --git a/base_layer/p2p/src/peer_seeds.rs b/base_layer/p2p/src/peer_seeds.rs index b55feeac2f..0e1311e431 100644 --- a/base_layer/p2p/src/peer_seeds.rs +++ b/base_layer/p2p/src/peer_seeds.rs @@ -160,8 +160,6 @@ impl From for Peer { #[cfg(test)] mod test { - use tari_utilities::hex::Hex; - use super::*; const TEST_NAME: &str = "test.local."; diff --git a/base_layer/p2p/src/services/liveness/service.rs b/base_layer/p2p/src/services/liveness/service.rs index 29724b946a..938afa8166 100644 --- a/base_layer/p2p/src/services/liveness/service.rs +++ b/base_layer/p2p/src/services/liveness/service.rs @@ -384,7 +384,7 @@ mod test { use tari_comms::{ message::MessageTag, net_address::MultiaddressesWithStats, - peer_manager::{NodeId, Peer, PeerFeatures, PeerFlags}, + peer_manager::{Peer, PeerFeatures, PeerFlags}, test_utils::mocks::create_connectivity_mock, }; use tari_comms_dht::{ diff --git a/base_layer/p2p/src/services/liveness/state.rs b/base_layer/p2p/src/services/liveness/state.rs index 0c2282811b..0c29d20d31 100644 --- a/base_layer/p2p/src/services/liveness/state.rs +++ b/base_layer/p2p/src/services/liveness/state.rs @@ -162,7 +162,7 @@ impl LivenessState { /// Returns true if the nonce is inflight, otherwise false pub fn is_inflight(&self, nonce: u64) -> bool { - self.inflight_pings.get(&nonce).is_some() + self.inflight_pings.contains_key(&nonce) } /// Records a pong. Specifically, the pong counter is incremented and @@ -345,8 +345,8 @@ mod test { state.add_inflight_ping(2, peer2.clone()); state.add_inflight_ping(3, peer2.clone()); - assert!(state.failed_pings.get(&peer1).is_none()); - assert!(state.failed_pings.get(&peer2).is_none()); + assert!(!state.failed_pings.contains_key(&peer1)); + assert!(!state.failed_pings.contains_key(&peer2)); // MAX_INFLIGHT_TTL passes for n in [1, 2, 3] { @@ -363,6 +363,6 @@ mod test { assert!(state.record_pong(2, &peer2).is_none()); let n = state.failed_pings.get(&peer1).unwrap(); assert_eq!(*n, 1); - assert!(state.failed_pings.get(&peer2).is_none()); + assert!(!state.failed_pings.contains_key(&peer2)); } } diff --git a/base_layer/service_framework/src/context/handles.rs b/base_layer/service_framework/src/context/handles.rs index 2042c8f4e8..1eb4bfce10 100644 --- a/base_layer/service_framework/src/context/handles.rs +++ b/base_layer/service_framework/src/context/handles.rs @@ -208,8 +208,6 @@ impl ServiceHandles { #[cfg(test)] mod test { - use tari_shutdown::Shutdown; - use super::*; #[test] diff --git a/base_layer/service_framework/src/context/lazy_service.rs b/base_layer/service_framework/src/context/lazy_service.rs index 313558f94d..c018ea1305 100644 --- a/base_layer/service_framework/src/context/lazy_service.rs +++ b/base_layer/service_framework/src/context/lazy_service.rs @@ -95,12 +95,9 @@ where #[cfg(test)] mod test { - use std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - task::Poll, + use std::sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }; use futures::future::{self, poll_fn}; diff --git a/base_layer/service_framework/src/stack.rs b/base_layer/service_framework/src/stack.rs index 34bb819a38..83eaf20a76 100644 --- a/base_layer/service_framework/src/stack.rs +++ b/base_layer/service_framework/src/stack.rs @@ -97,12 +97,11 @@ mod test { }; use async_trait::async_trait; - use futures::{executor::block_on, future}; + use futures::executor::block_on; use tari_shutdown::Shutdown; use tower::service_fn; use super::*; - use crate::{initializer::ServiceInitializer, ServiceInitializerContext}; #[tokio::test] async fn service_defn_simple() { diff --git a/base_layer/service_framework/src/tower/service_ext.rs b/base_layer/service_framework/src/tower/service_ext.rs index 6c0a506792..cd52890f5f 100644 --- a/base_layer/service_framework/src/tower/service_ext.rs +++ b/base_layer/service_framework/src/tower/service_ext.rs @@ -93,7 +93,7 @@ mod test { Arc, }; - use futures::{future, FutureExt}; + use futures::future; use futures_test::task::panic_context; use tower::service_fn; diff --git a/base_layer/tari_mining_helper_ffi/src/lib.rs b/base_layer/tari_mining_helper_ffi/src/lib.rs index 8888fb8e52..ede36a6464 100644 --- a/base_layer/tari_mining_helper_ffi/src/lib.rs +++ b/base_layer/tari_mining_helper_ffi/src/lib.rs @@ -566,8 +566,6 @@ pub unsafe extern "C" fn share_validate( #[cfg(test)] mod tests { - use libc::c_int; - use tari_common::configuration::Network; use tari_core::{ blocks::{genesis_block::get_genesis_block, Block}, proof_of_work::Difficulty, @@ -575,7 +573,6 @@ mod tests { }; use super::*; - use crate::{inject_nonce, public_key_hex_validate, share_difficulty, share_validate}; fn min_difficulty() -> Difficulty { Difficulty::from_u64(1000).expect("Failed to create difficulty") diff --git a/base_layer/wallet/src/lib.rs b/base_layer/wallet/src/lib.rs index 5550b7e529..8c550aec9d 100644 --- a/base_layer/wallet/src/lib.rs +++ b/base_layer/wallet/src/lib.rs @@ -17,7 +17,6 @@ pub mod output_manager_service; pub mod storage; pub mod test_utils; pub mod transaction_service; -pub mod types; pub use tari_common_types::types::WalletHasher; pub mod util; diff --git a/base_layer/wallet/src/output_manager_service/storage/output_source.rs b/base_layer/wallet/src/output_manager_service/storage/output_source.rs index d64b7f8d26..19d178f0df 100644 --- a/base_layer/wallet/src/output_manager_service/storage/output_source.rs +++ b/base_layer/wallet/src/output_manager_service/storage/output_source.rs @@ -19,13 +19,7 @@ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::{ - convert::TryFrom, - result::{ - Result, - Result::{Err, Ok}, - }, -}; +use core::convert::TryFrom; use strum_macros::Display; diff --git a/base_layer/wallet/src/output_manager_service/storage/output_status.rs b/base_layer/wallet/src/output_manager_service/storage/output_status.rs index 495cc72e37..76e4ecf1ab 100644 --- a/base_layer/wallet/src/output_manager_service/storage/output_status.rs +++ b/base_layer/wallet/src/output_manager_service/storage/output_status.rs @@ -19,13 +19,7 @@ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::{ - convert::TryFrom, - result::{ - Result, - Result::{Err, Ok}, - }, -}; +use core::convert::TryFrom; use strum_macros::Display; diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs index 8e0018044d..35d937adfa 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs @@ -29,7 +29,6 @@ use diesel::{ prelude::*, r2d2::{ConnectionManager, PooledConnection}, result::Error as DieselError, - SqliteConnection, }; use log::*; pub use new_output_sql::NewOutputSql; diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs index 634ec87098..b6f03d9fb9 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/new_output_sql.rs @@ -22,7 +22,7 @@ use borsh::BorshSerialize; // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. use derivative::Derivative; -use diesel::{prelude::*, SqliteConnection}; +use diesel::prelude::*; use tari_common_types::transaction::TxId; use tari_utilities::ByteArray; diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs index 83d7d2478c..95e6449ef3 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs @@ -28,7 +28,7 @@ use std::{ use borsh::BorshDeserialize; use chrono::NaiveDateTime; use derivative::Derivative; -use diesel::{prelude::*, sql_query, SqliteConnection}; +use diesel::{prelude::*, sql_query}; use log::*; use tari_common_sqlite::util::diesel_ext::ExpectedRowsExtension; use tari_common_types::{ diff --git a/base_layer/wallet/src/storage/sqlite_db/wallet.rs b/base_layer/wallet/src/storage/sqlite_db/wallet.rs index 5be73d2888..f788dd8075 100644 --- a/base_layer/wallet/src/storage/sqlite_db/wallet.rs +++ b/base_layer/wallet/src/storage/sqlite_db/wallet.rs @@ -34,7 +34,7 @@ use argon2::password_hash::{ use blake2::Blake2b; use chacha20poly1305::{Key, KeyInit, XChaCha20Poly1305}; use chrono::NaiveDateTime; -use diesel::{prelude::*, result::Error, SqliteConnection}; +use diesel::{prelude::*, result::Error}; use digest::{consts::U32, generic_array::GenericArray, FixedOutput}; use itertools::Itertools; use log::*; diff --git a/base_layer/wallet/src/transaction_service/service.rs b/base_layer/wallet/src/transaction_service/service.rs index c187c1cf10..3054de0136 100644 --- a/base_layer/wallet/src/transaction_service/service.rs +++ b/base_layer/wallet/src/transaction_service/service.rs @@ -2996,7 +2996,7 @@ pub struct TransactionSendResult { #[cfg(test)] mod tests { use tari_crypto::ristretto::RistrettoSecretKey; - use tari_script::{stealth_payment_script, Opcode}; + use tari_script::Opcode; use super::*; diff --git a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs index 010b35d342..74e18145ed 100644 --- a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs +++ b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs @@ -28,7 +28,7 @@ use std::{ use chacha20poly1305::XChaCha20Poly1305; use chrono::{NaiveDateTime, Utc}; -use diesel::{prelude::*, result::Error as DieselError, SqliteConnection}; +use diesel::{prelude::*, result::Error as DieselError}; use log::*; use tari_common_sqlite::{sqlite_connection_pool::PooledDbConnection, util::diesel_ext::ExpectedRowsExtension}; use tari_common_types::{ @@ -2155,7 +2155,7 @@ impl UnconfirmedTransactionInfoSql { #[cfg(test)] mod test { - use std::{default::Default, mem::size_of, time::Duration}; + use std::{mem::size_of, time::Duration}; use chacha20poly1305::{Key, KeyInit, XChaCha20Poly1305}; use chrono::Utc; diff --git a/base_layer/wallet/src/types.rs b/base_layer/wallet/src/types.rs deleted file mode 100644 index 97ad8c685e..0000000000 --- a/base_layer/wallet/src/types.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -use tari_common_types::types::PublicKey; - -use crate::error::WalletError; - -pub(crate) trait PersistentKeyManager { - fn create_and_store_new(&mut self) -> Result; -} diff --git a/base_layer/wallet/tests/transaction_service_tests/storage.rs b/base_layer/wallet/tests/transaction_service_tests/storage.rs index bf32ac5ca4..4feeeacf7e 100644 --- a/base_layer/wallet/tests/transaction_service_tests/storage.rs +++ b/base_layer/wallet/tests/transaction_service_tests/storage.rs @@ -20,7 +20,6 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::default::Default; use std::mem::size_of; use chacha20poly1305::{Key, KeyInit, XChaCha20Poly1305}; diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index ef7cdff9de..0d4e70c2b5 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -49,7 +49,6 @@ use core::ptr; use std::{ - boxed::Box, convert::{TryFrom, TryInto}, ffi::{CStr, CString}, fmt::{Display, Formatter}, @@ -67,7 +66,7 @@ use error::LibWalletError; use ffi_basenode_state::TariBaseNodeState; use itertools::Itertools; use libc::{c_char, c_int, c_uchar, c_uint, c_ulonglong, c_ushort, c_void}; -use log::{LevelFilter, *}; +use log::*; use log4rs::{ append::{ file::FileAppender, @@ -8727,20 +8726,14 @@ pub unsafe extern "C" fn contacts_handle_destroy(contacts_handle: *mut ContactsS /// ------------------------------------------------------------------------------------------ /// #[cfg(test)] mod test { - use std::{ - ffi::CString, - path::Path, - str::{from_utf8, FromStr}, - sync::Mutex, - }; + use std::{path::Path, str::from_utf8, sync::Mutex}; - use libc::{c_char, c_uchar, c_uint}; use minotari_wallet::{ storage::sqlite_utilities::run_migration_and_create_sqlite_connection, transaction_service::handle::TransactionSendStatus, }; use once_cell::sync::Lazy; - use tari_common_types::{emoji, transaction::TransactionStatus, types::PrivateKey}; + use tari_common_types::emoji; use tari_comms::peer_manager::PeerFeatures; use tari_contacts::contacts_service::types::{Direction, Message, MessageMetadata}; use tari_core::{ @@ -8750,7 +8743,7 @@ mod test { test_helpers::{create_test_input, create_wallet_output_with_data, TestParams}, }, }; - use tari_key_manager::{mnemonic::MnemonicLanguage, mnemonic_wordlists}; + use tari_key_manager::mnemonic_wordlists; use tari_p2p::initialization::MESSAGING_PROTOCOL_ID; use tari_script::script; use tari_test_utils::random; @@ -9306,6 +9299,8 @@ mod test { #[test] fn test_encrypted_data_filled() { + use tari_common_types::types::PrivateKey; + unsafe { let mut error = 0; let error_ptr = &mut error as *mut c_int; diff --git a/common/src/configuration/name_server.rs b/common/src/configuration/name_server.rs index 55fff6b575..d432d0c405 100644 --- a/common/src/configuration/name_server.rs +++ b/common/src/configuration/name_server.rs @@ -63,7 +63,7 @@ impl FromStr for DnsNameServer { #[cfg(test)] mod test { - use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + use std::net::{IpAddr, Ipv4Addr}; use super::*; diff --git a/common_sqlite/src/connection_options.rs b/common_sqlite/src/connection_options.rs index 5fdbb3f98b..e80e027302 100644 --- a/common_sqlite/src/connection_options.rs +++ b/common_sqlite/src/connection_options.rs @@ -20,11 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::{ - option::{Option, Option::Some}, - result::{Result, Result::Ok}, - time::Duration, -}; +use core::time::Duration; use diesel::{connection::SimpleConnection, SqliteConnection}; diff --git a/common_sqlite/src/error.rs b/common_sqlite/src/error.rs index 7bf0d6f9e8..de5875786b 100644 --- a/common_sqlite/src/error.rs +++ b/common_sqlite/src/error.rs @@ -22,7 +22,7 @@ use std::num::TryFromIntError; -use diesel::{self, r2d2}; +use diesel::r2d2; use tari_utilities::message_format::MessageFormatError; use thiserror::Error; use tokio::task; diff --git a/common_sqlite/src/sqlite_connection_pool.rs b/common_sqlite/src/sqlite_connection_pool.rs index 1c70fbca93..95ecf1b246 100644 --- a/common_sqlite/src/sqlite_connection_pool.rs +++ b/common_sqlite/src/sqlite_connection_pool.rs @@ -20,14 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use core::{ - option::Option::{None, Some}, - result::{ - Result, - Result::{Err, Ok}, - }, - time::Duration, -}; +use core::time::Duration; use std::convert::TryFrom; use diesel::{ diff --git a/comms/core/src/bounded_executor.rs b/comms/core/src/bounded_executor.rs index 2ce811083d..492d128913 100644 --- a/comms/core/src/bounded_executor.rs +++ b/comms/core/src/bounded_executor.rs @@ -156,10 +156,7 @@ impl BoundedExecutor { #[cfg(test)] mod test { use std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, + sync::atomic::{AtomicBool, Ordering}, time::Duration, }; diff --git a/comms/core/src/connection_manager/dialer.rs b/comms/core/src/connection_manager/dialer.rs index 8226eab9d5..a8490543bf 100644 --- a/comms/core/src/connection_manager/dialer.rs +++ b/comms/core/src/connection_manager/dialer.rs @@ -39,7 +39,7 @@ use tokio::{ time, }; use tokio_stream::StreamExt; -use tracing::{self, span, Instrument, Level}; +use tracing::{span, Instrument, Level}; use super::{direction::ConnectionDirection, error::ConnectionManagerError, peer_connection::PeerConnection}; #[cfg(feature = "metrics")] diff --git a/comms/core/src/connection_manager/liveness.rs b/comms/core/src/connection_manager/liveness.rs index f5dd83e08a..f05819f560 100644 --- a/comms/core/src/connection_manager/liveness.rs +++ b/comms/core/src/connection_manager/liveness.rs @@ -190,8 +190,6 @@ where #[cfg(test)] mod test { - use futures::SinkExt; - use tokio::{time, time::Duration}; use tokio_stream::StreamExt; use super::*; diff --git a/comms/core/src/connection_manager/peer_connection.rs b/comms/core/src/connection_manager/peer_connection.rs index c8e86f2394..f52ae0937a 100644 --- a/comms/core/src/connection_manager/peer_connection.rs +++ b/comms/core/src/connection_manager/peer_connection.rs @@ -38,7 +38,7 @@ use tokio::{ time, }; use tokio_stream::StreamExt; -use tracing::{self, span, Instrument, Level}; +use tracing::{span, Instrument, Level}; use super::{direction::ConnectionDirection, error::PeerConnectionError, manager::ConnectionManagerEvent}; #[cfg(feature = "rpc")] diff --git a/comms/core/src/multiplexing/yamux.rs b/comms/core/src/multiplexing/yamux.rs index 5e16dfc459..ea3362ac38 100644 --- a/comms/core/src/multiplexing/yamux.rs +++ b/comms/core/src/multiplexing/yamux.rs @@ -28,7 +28,7 @@ use tokio::{ sync::mpsc, }; use tokio_util::compat::{Compat, FuturesAsyncReadCompatExt, TokioAsyncReadCompatExt}; -use tracing::{self, debug, error}; +use tracing::{debug, error}; // Reexport pub use yamux::ConnectionError; use yamux::Mode; diff --git a/comms/core/src/net_address/multiaddr_with_stats.rs b/comms/core/src/net_address/multiaddr_with_stats.rs index b357168fd6..30f9932b1b 100644 --- a/comms/core/src/net_address/multiaddr_with_stats.rs +++ b/comms/core/src/net_address/multiaddr_with_stats.rs @@ -3,7 +3,7 @@ use std::{ cmp, - cmp::{Ord, Ordering}, + cmp::Ordering, convert::{TryFrom, TryInto}, fmt, fmt::{Display, Formatter}, @@ -375,8 +375,6 @@ impl PartialEq for PeerAddressSource { } #[cfg(test)] mod test { - use std::time::Duration; - use super::*; #[test] diff --git a/comms/core/src/net_address/mutliaddresses_with_stats.rs b/comms/core/src/net_address/mutliaddresses_with_stats.rs index 9d7c9d9e4b..a1460395f1 100644 --- a/comms/core/src/net_address/mutliaddresses_with_stats.rs +++ b/comms/core/src/net_address/mutliaddresses_with_stats.rs @@ -291,8 +291,6 @@ impl Display for MultiaddressesWithStats { #[cfg(test)] mod test { - use multiaddr::Multiaddr; - use super::*; #[test] diff --git a/comms/core/src/noise/config.rs b/comms/core/src/noise/config.rs index 1310dfdb89..a18ab1af50 100644 --- a/comms/core/src/noise/config.rs +++ b/comms/core/src/noise/config.rs @@ -25,7 +25,7 @@ use std::{sync::Arc, time::Duration}; use log::*; -use snow::{self, params::NoiseParams}; +use snow::params::NoiseParams; use tari_utilities::ByteArray; use tokio::io::{AsyncRead, AsyncWrite}; diff --git a/comms/core/src/noise/socket.rs b/comms/core/src/noise/socket.rs index fefeb50fcd..bbe3be4b1f 100644 --- a/comms/core/src/noise/socket.rs +++ b/comms/core/src/noise/socket.rs @@ -662,8 +662,6 @@ impl From for NoiseState { #[cfg(test)] mod test { - use std::io; - use futures::future::join; use snow::{params::NoiseParams, Builder, Error, Keypair}; diff --git a/comms/core/src/peer_manager/manager.rs b/comms/core/src/peer_manager/manager.rs index a383fdf437..93a24feb68 100644 --- a/comms/core/src/peer_manager/manager.rs +++ b/comms/core/src/peer_manager/manager.rs @@ -375,14 +375,6 @@ mod test { use tari_storage::HashmapDatabase; use super::*; - use crate::{ - net_address::MultiaddressesWithStats, - peer_manager::{ - node_id::NodeId, - peer::{Peer, PeerFlags}, - PeerFeatures, - }, - }; fn create_test_peer(ban_flag: bool, features: PeerFeatures) -> Peer { let (_sk, pk) = RistrettoPublicKey::random_keypair(&mut OsRng); diff --git a/comms/core/src/peer_manager/node_id.rs b/comms/core/src/peer_manager/node_id.rs index f6eca4fc68..378847bdcb 100644 --- a/comms/core/src/peer_manager/node_id.rs +++ b/comms/core/src/peer_manager/node_id.rs @@ -265,13 +265,10 @@ where D: Deserializer<'de> { #[cfg(test)] mod test { - use tari_crypto::{ - keys::{PublicKey, SecretKey}, - tari_utilities::byte_array::ByteArray, - }; + use tari_crypto::keys::{PublicKey, SecretKey}; use super::*; - use crate::types::{CommsPublicKey, CommsSecretKey}; + use crate::types::CommsSecretKey; #[test] fn display() { diff --git a/comms/core/src/peer_manager/peer.rs b/comms/core/src/peer_manager/peer.rs index 3ec13afe13..45c9794579 100644 --- a/comms/core/src/peer_manager/peer.rs +++ b/comms/core/src/peer_manager/peer.rs @@ -341,7 +341,6 @@ mod test { }; use super::*; - use crate::{net_address::MultiaddressesWithStats, peer_manager::NodeId, types::CommsPublicKey}; #[test] fn test_is_banned_and_ban_for() { diff --git a/comms/core/src/peer_manager/peer_query.rs b/comms/core/src/peer_manager/peer_query.rs index 71f56b3fd7..07b558807e 100644 --- a/comms/core/src/peer_manager/peer_query.rs +++ b/comms/core/src/peer_manager/peer_query.rs @@ -215,11 +215,7 @@ mod test { use super::*; use crate::{ net_address::{MultiaddressesWithStats, PeerAddressSource}, - peer_manager::{ - node_id::NodeId, - peer::{Peer, PeerFlags}, - PeerFeatures, - }, + peer_manager::{peer::PeerFlags, PeerFeatures}, }; fn create_test_peer(ban_flag: bool) -> Peer { diff --git a/comms/core/src/peer_manager/peer_storage.rs b/comms/core/src/peer_manager/peer_storage.rs index 760d823cf3..43e462968a 100644 --- a/comms/core/src/peer_manager/peer_storage.rs +++ b/comms/core/src/peer_manager/peer_storage.rs @@ -538,7 +538,7 @@ mod test { use super::*; use crate::{ net_address::{MultiaddrWithStats, MultiaddressesWithStats, PeerAddressSource}, - peer_manager::{peer::PeerFlags, PeerFeatures}, + peer_manager::peer::PeerFlags, }; #[test] diff --git a/comms/core/src/peer_validator/helpers.rs b/comms/core/src/peer_validator/helpers.rs index 99e1eaa386..4b6b47f910 100644 --- a/comms/core/src/peer_validator/helpers.rs +++ b/comms/core/src/peer_validator/helpers.rs @@ -200,7 +200,6 @@ mod test { use multiaddr::multiaddr; use super::*; - use crate::peer_validator::error::PeerValidatorError; #[test] fn validate_address_strict() { diff --git a/comms/core/src/pipeline/inbound.rs b/comms/core/src/pipeline/inbound.rs index 6b0149b12e..12ed95aa7f 100644 --- a/comms/core/src/pipeline/inbound.rs +++ b/comms/core/src/pipeline/inbound.rs @@ -137,12 +137,9 @@ where #[cfg(test)] mod test { - use std::time::Duration; - use futures::future; use tari_shutdown::Shutdown; use tari_test_utils::collect_recv; - use tokio::{sync::mpsc, time}; use tower::service_fn; use super::*; diff --git a/comms/core/src/pipeline/outbound.rs b/comms/core/src/pipeline/outbound.rs index 6a8730689f..1141ca8bfe 100644 --- a/comms/core/src/pipeline/outbound.rs +++ b/comms/core/src/pipeline/outbound.rs @@ -119,11 +119,9 @@ where #[cfg(test)] mod test { - use std::time::Duration; - use bytes::Bytes; use tari_test_utils::collect_recv; - use tokio::{sync::mpsc, time}; + use tokio::sync::mpsc; use super::*; use crate::{message::OutboundMessage, pipeline::SinkService, utils}; diff --git a/comms/core/src/tor/control_client/client.rs b/comms/core/src/tor/control_client/client.rs index f9ce4f0e29..ce35453b5c 100644 --- a/comms/core/src/tor/control_client/client.rs +++ b/comms/core/src/tor/control_client/client.rs @@ -279,7 +279,7 @@ mod test { use tokio_stream::StreamExt; use super::*; - use crate::tor::control_client::{test_server, test_server::canned_responses, types::PrivateKey}; + use crate::tor::control_client::{test_server, test_server::canned_responses}; async fn setup_test() -> (TorControlPortClient, test_server::State) { let (_, mock_state, socket) = test_server::spawn().await; diff --git a/comms/dht/examples/graphing_utilities/utilities.rs b/comms/dht/examples/graphing_utilities/utilities.rs index 1e3b63a047..bffb93b2b5 100644 --- a/comms/dht/examples/graphing_utilities/utilities.rs +++ b/comms/dht/examples/graphing_utilities/utilities.rs @@ -43,7 +43,7 @@ static GRAPH_FRAME_NUM: Lazy>> = Lazy::new(|| Mutex fn get_next_frame_num(name: &str) -> usize { let mut map = GRAPH_FRAME_NUM.lock().unwrap(); let current: usize; - match (*map).get_mut(&name.to_string()) { + match (*map).get_mut(name) { None => { current = 0; (*map).insert(name.to_string(), 1); diff --git a/comms/dht/src/actor.rs b/comms/dht/src/actor.rs index 819cf7075b..6f86bf3df3 100644 --- a/comms/dht/src/actor.rs +++ b/comms/dht/src/actor.rs @@ -879,7 +879,6 @@ impl DiscoveryDialTask { mod test { use std::{convert::TryFrom, time::Duration}; - use chrono::{DateTime, Utc}; use tari_comms::test_utils::mocks::{ create_connectivity_mock, create_peer_connection_mock_pair, @@ -890,7 +889,6 @@ mod test { use super::*; use crate::{ - broadcast_strategy::BroadcastClosestRequest, envelope::NodeDestination, test_utils::{ build_peer_manager, diff --git a/comms/dht/src/crypt.rs b/comms/dht/src/crypt.rs index 4530ef771d..2f5196e013 100644 --- a/comms/dht/src/crypt.rs +++ b/comms/dht/src/crypt.rs @@ -283,7 +283,6 @@ pub fn create_message_domain_separated_hash_parts( mod test { use prost::Message; use rand::rngs::OsRng; - use tari_comms::message::MessageExt; use tari_crypto::keys::PublicKey; use super::*; diff --git a/comms/dht/src/dht.rs b/comms/dht/src/dht.rs index 62f2d5a0f7..3866ade9f6 100644 --- a/comms/dht/src/dht.rs +++ b/comms/dht/src/dht.rs @@ -452,7 +452,7 @@ fn discard_expired_messages(msg: &DhtInboundMessage) -> bool { #[cfg(test)] mod test { - use std::{sync::Arc, time::Duration}; + use std::time::Duration; use tari_comms::{ message::{MessageExt, MessageTag}, @@ -462,15 +462,13 @@ mod test { wrap_in_envelope_body, }; use tari_shutdown::Shutdown; - use tokio::{sync::mpsc, task, time}; - use tower::{layer::Layer, Service}; + use tokio::{task, time}; use super::*; use crate::{ crypt, envelope::DhtMessageFlags, outbound::mock::create_outbound_service_mock, - proto::envelope::DhtMessageType, test_utils::{ build_peer_manager, make_client_identity, diff --git a/comms/dht/src/outbound/broadcast.rs b/comms/dht/src/outbound/broadcast.rs index 5a06922866..b87d00a1e3 100644 --- a/comms/dht/src/outbound/broadcast.rs +++ b/comms/dht/src/outbound/broadcast.rs @@ -559,16 +559,13 @@ where S: Service mod test { use std::time::Duration; - use rand::rngs::OsRng; use tari_comms::{ multiaddr::Multiaddr, net_address::{MultiaddressesWithStats, PeerAddressSource}, - peer_manager::{NodeId, Peer, PeerFeatures, PeerFlags}, - types::CommsPublicKey, + peer_manager::{PeerFeatures, PeerFlags}, }; - use tari_crypto::keys::PublicKey; use tari_test_utils::unpack_enum; - use tokio::{sync::oneshot, task}; + use tokio::task; use super::*; use crate::{ diff --git a/comms/dht/src/peer_validator.rs b/comms/dht/src/peer_validator.rs index a3d65bc0a5..ade894c2db 100644 --- a/comms/dht/src/peer_validator.rs +++ b/comms/dht/src/peer_validator.rs @@ -111,7 +111,6 @@ mod tests { use tari_comms::{ multiaddr::Multiaddr, - net_address::MultiaddressesWithStats, peer_manager::{IdentitySignature, PeerFeatures, PeerIdentityClaim}, types::Signature, }; diff --git a/comms/dht/src/rpc/test.rs b/comms/dht/src/rpc/test.rs index 5d245586cf..0b147fddeb 100644 --- a/comms/dht/src/rpc/test.rs +++ b/comms/dht/src/rpc/test.rs @@ -191,7 +191,7 @@ mod get_closer_peers { } mod get_peers { - use std::{borrow::BorrowMut, time::Duration}; + use std::borrow::BorrowMut; use tari_comms::test_utils::node_identity::build_many_node_identities; diff --git a/comms/dht/src/store_forward/saf_handler/task.rs b/comms/dht/src/store_forward/saf_handler/task.rs index e630d84c41..bb51854f4b 100644 --- a/comms/dht/src/store_forward/saf_handler/task.rs +++ b/comms/dht/src/store_forward/saf_handler/task.rs @@ -752,11 +752,11 @@ where S: Service mod test { use std::time::Duration; - use chrono::{Timelike, Utc}; + use chrono::Timelike; use tari_comms::{message::MessageExt, wrap_in_envelope_body}; use tari_test_utils::collect_recv; use tari_utilities::{hex, hex::Hex}; - use tokio::{sync::mpsc, task, time::sleep}; + use tokio::{task, time::sleep}; use super::*; use crate::{ diff --git a/infrastructure/tari_script/src/op_codes.rs b/infrastructure/tari_script/src/op_codes.rs index 5e91c529fd..8fe2f96b64 100644 --- a/infrastructure/tari_script/src/op_codes.rs +++ b/infrastructure/tari_script/src/op_codes.rs @@ -642,7 +642,7 @@ pub enum OpcodeVersion { #[cfg(test)] mod test { - use crate::{op_codes::*, Opcode, ScriptError}; + use crate::op_codes::*; #[test] fn empty_script() { diff --git a/infrastructure/tari_script/src/script.rs b/infrastructure/tari_script/src/script.rs index 091c03b973..ab07a14323 100644 --- a/infrastructure/tari_script/src/script.rs +++ b/infrastructure/tari_script/src/script.rs @@ -16,7 +16,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // pending updates to Dalek/Digest -use std::{cmp::Ordering, collections::HashSet, convert::TryFrom, fmt, io, ops::Deref}; +use std::{cmp::Ordering, collections::HashSet, fmt, io, ops::Deref}; use blake2::Blake2b; use borsh::{BorshDeserialize, BorshSerialize}; diff --git a/infrastructure/tari_script/src/stack.rs b/infrastructure/tari_script/src/stack.rs index 38185e4c89..111cfb4e50 100644 --- a/infrastructure/tari_script/src/stack.rs +++ b/infrastructure/tari_script/src/stack.rs @@ -15,7 +15,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{convert::TryFrom, io}; +use std::io; use borsh::{BorshDeserialize, BorshSerialize}; use integer_encoding::{VarIntReader, VarIntWriter}; diff --git a/integration_tests/src/base_node_process.rs b/integration_tests/src/base_node_process.rs index 675bee11ff..83c14f7908 100644 --- a/integration_tests/src/base_node_process.rs +++ b/integration_tests/src/base_node_process.rs @@ -21,7 +21,6 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use std::{ - default::Default, fmt::{Debug, Formatter}, path::PathBuf, str::FromStr, diff --git a/integration_tests/src/transaction.rs b/integration_tests/src/transaction.rs index d358d9f63b..051ffb9d29 100644 --- a/integration_tests/src/transaction.rs +++ b/integration_tests/src/transaction.rs @@ -20,8 +20,6 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::default::Default; - use tari_core::{ borsh::SerializedSize, covenants::Covenant, diff --git a/lints.toml b/lints.toml index cb44026f34..9b37a15a3e 100644 --- a/lints.toml +++ b/lints.toml @@ -15,7 +15,6 @@ deny = [ # Common mistakes 'clippy::await_holding_lock', 'unused_variables', - 'unused_imports', 'dead_code', 'unused_extern_crates', 'unused_must_use', @@ -70,4 +69,5 @@ allow = [ # `assert!(!foo(bar))` is misread the majority of the time, while `assert_eq!(foo(bar), false)` is crystal clear 'clippy::bool-assert-comparison', 'clippy::blocks_in_conditions', + 'unused_imports', # TODO: DENY THIS ]