Skip to content

Commit

Permalink
Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeickert committed Apr 17, 2024
1 parent c83c0b6 commit 5249bad
Show file tree
Hide file tree
Showing 105 changed files with 97 additions and 305 deletions.
21 changes: 5 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion applications/minotari_miner/src/stratum/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion applications/minotari_miner/src/stratum/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 0 additions & 2 deletions base_layer/chat_ffi/src/contacts_liveness_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions base_layer/chat_ffi/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
10 changes: 1 addition & 9 deletions base_layer/chat_ffi/src/message_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down
6 changes: 1 addition & 5 deletions base_layer/common_types/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
2 changes: 1 addition & 1 deletion base_layer/contacts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 2 additions & 9 deletions base_layer/contacts/src/contacts_service/storage/sqlite_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,16 @@ where TContactServiceDbConnection: PooledDbConnection<Error = SqliteStorageError

#[cfg(test)]
mod test {
use std::convert::{TryFrom, TryInto};
use std::convert::TryInto;

use rand::rngs::OsRng;
use tari_common::configuration::Network;
use tari_common_sqlite::connection::{DbConnection, DbConnectionUrl};
use tari_common_types::{
tari_address::TariAddress,
types::{PrivateKey, PublicKey},
};
use tari_common_types::types::{PrivateKey, PublicKey};
use tari_crypto::keys::{PublicKey as PublicKeyTrait, SecretKey as SecretKeyTrait};
use tari_test_utils::{paths::with_temp_dir, random::string};

use super::*;
use crate::contacts_service::{
storage::types::contacts::{ContactSql, UpdateContact},
types::Contact,
};

#[test]
fn test_crud() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::convert::TryFrom;

use chrono::NaiveDateTime;
use diesel::{prelude::*, SqliteConnection};
use diesel::prelude::*;
use tari_common_sqlite::util::diesel_ext::ExpectedRowsExtension;
use tari_common_types::tari_address::TariAddress;
use tari_comms::peer_manager::NodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
use std::convert::TryFrom;

use chrono::NaiveDateTime;
use diesel::{prelude::*, SqliteConnection};
use serde_json;
use diesel::prelude::*;
use tari_common_sqlite::util::diesel_ext::ExpectedRowsExtension;
use tari_common_types::tari_address::TariAddress;

Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ log-mdc = "0.1.0"
monero = { version = "0.20.0", features = ["serde-crate"], optional = true }
newtype-ops = "0.1.4"
num-traits = "0.2.15"
num-derive = "0.3.3"
num-derive = "0.4.2"
num-format = "0.4.0"
once_cell = "1.8.0"
prost = "0.11.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,11 @@ mod test {
mock::{create_p2p_liveness_mock, LivenessMockState},
LivenessRequest,
Metadata,
PingPongEvent,
};
use tari_service_framework::reply_channel;
use tari_test_utils::unpack_enum;
use tari_utilities::epoch_time::EpochTime;
use tokio::{sync::broadcast, task};
use tokio::task;

use super::*;
use crate::base_node::comms_interface::{CommsInterfaceError, NodeCommsRequest, NodeCommsResponse};
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/src/base_node/proto/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, TryInto};
use std::convert::{TryFrom, TryInto};

use tari_common_types::types::PrivateKey;
use tari_utilities::ByteArray;
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/src/base_node/proto/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use std::{
convert::{TryFrom, TryInto},
iter::{FromIterator, Iterator},
iter::FromIterator,
sync::Arc,
};

Expand Down
7 changes: 2 additions & 5 deletions base_layer/core/src/base_node/sync/header_sync/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ mod test {

use super::*;
use crate::{
blocks::{BlockHeader, BlockHeaderAccumulatedData},
chain_storage::async_db::AsyncBlockchainDb,
consensus::ConsensusManager,
proof_of_work::{randomx_factory::RandomXFactory, PowAlgorithm},
blocks::BlockHeader,
proof_of_work::PowAlgorithm,
test_helpers::blockchain::{create_new_blockchain, TempDatabase},
};

Expand Down Expand Up @@ -316,7 +314,6 @@ mod test {

mod validate {
use super::*;
use crate::{blocks::BlockHeaderValidationError, validation::ValidationError};

#[tokio::test]
async fn it_passes_if_headers_are_valid() {
Expand Down
1 change: 0 additions & 1 deletion base_layer/core/src/base_node/sync/sync_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ mod test {
use tari_crypto::keys::{PublicKey, SecretKey};

use super::*;
use crate::base_node::chain_metadata_service::PeerChainMetadata;

// Helper function to generate a peer with a given latency
fn generate_peer(latency: Option<usize>) -> SyncPeer {
Expand Down
2 changes: 0 additions & 2 deletions base_layer/core/src/blocks/genesis_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 0 additions & 2 deletions base_layer/core/src/chain_storage/blockchain_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,6 @@ mod test {
chain_strength_comparer::strongest_chain,
consensus_constants::PowAlgorithmConstants,
ConsensusConstantsBuilder,
ConsensusManager,
},
proof_of_work::Difficulty,
test_helpers::{
Expand Down Expand Up @@ -2910,7 +2909,6 @@ mod test {

mod handle_possible_reorg {
use super::*;
use crate::test_helpers::blockchain::update_block_and_smt;

#[ignore]
#[tokio::test]
Expand Down
2 changes: 0 additions & 2 deletions base_layer/core/src/common/limited_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ impl<R: Read> Read for LimitedBytesReader<R> {

#[cfg(test)]
mod test {
use std::io::Read;

use super::*;

impl<R: Read> LimitedBytesReader<R> {
Expand Down
2 changes: 0 additions & 2 deletions base_layer/core/src/common/one_sided.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl<M: DomainSeparation, D: Digest + Default> 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;

Expand Down
8 changes: 1 addition & 7 deletions base_layer/core/src/covenants/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 2 additions & 4 deletions base_layer/core/src/proof_of_work/monero_rx/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/src/proof_of_work/proof_of_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5249bad

Please sign in to comment.