Skip to content

Commit

Permalink
Sigh... more lints
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeickert committed Apr 8, 2024
1 parent c6ad891 commit 5434608
Show file tree
Hide file tree
Showing 29 changed files with 20 additions and 69 deletions.
6 changes: 1 addition & 5 deletions base_layer/common_types/src/encryption.rs
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
1 change: 0 additions & 1 deletion base_layer/mmr/src/merkle_mountain_range.rs
Expand Up @@ -23,7 +23,6 @@
use std::{
cmp::{max, min},
convert::TryInto,
iter::IntoIterator,
marker::PhantomData,
};

Expand Down
1 change: 0 additions & 1 deletion base_layer/mmr/src/sparse_merkle_tree/bit_utils.rs
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions base_layer/mmr/src/sparse_merkle_tree/node.rs
Expand Up @@ -510,8 +510,7 @@ impl<H: Digest<OutputSize = U32>> BranchNode<H> {
#[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};
Expand Down
1 change: 0 additions & 1 deletion base_layer/mmr/src/sparse_merkle_tree/proofs.rs
Expand Up @@ -227,7 +227,6 @@ impl<H: Digest<OutputSize = U32>> MerkleProofDigest<H> for ExclusionProof<H> {
#[cfg(test)]
mod test {
use blake2::Blake2b;
use digest::consts::U32;

use super::*;

Expand Down
2 changes: 0 additions & 2 deletions base_layer/mmr/tests/tests/with_blake512_hash.rs
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 std::string::ToString;

use blake2::Blake2b;
use digest::consts::U64;
use tari_crypto::{hash_domain, hashing::DomainSeparatedHasher};
Expand Down
2 changes: 0 additions & 2 deletions base_layer/service_framework/src/context/handles.rs
Expand Up @@ -208,8 +208,6 @@ impl ServiceHandles {

#[cfg(test)]
mod test {
use tari_shutdown::Shutdown;

use super::*;

#[test]
Expand Down
9 changes: 3 additions & 6 deletions base_layer/service_framework/src/context/lazy_service.rs
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions base_layer/service_framework/src/stack.rs
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion base_layer/service_framework/src/tower/service_ext.rs
Expand Up @@ -93,7 +93,7 @@ mod test {
Arc,
};

use futures::{future, FutureExt};
use futures::future;
use futures_test::task::panic_context;
use tower::service_fn;

Expand Down
2 changes: 1 addition & 1 deletion common/src/configuration/name_server.rs
Expand Up @@ -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::*;

Expand Down
5 changes: 1 addition & 4 deletions comms/core/src/bounded_executor.rs
Expand Up @@ -156,10 +156,7 @@ impl BoundedExecutor {
#[cfg(test)]
mod test {
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
sync::atomic::{AtomicBool, Ordering},
time::Duration,
};

Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/connection_manager/dialer.rs
Expand Up @@ -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")]
Expand Down
2 changes: 0 additions & 2 deletions comms/core/src/connection_manager/liveness.rs
Expand Up @@ -190,8 +190,6 @@ where

#[cfg(test)]
mod test {
use futures::SinkExt;
use tokio::{time, time::Duration};
use tokio_stream::StreamExt;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/connection_manager/peer_connection.rs
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/multiplexing/yamux.rs
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions comms/core/src/net_address/multiaddr_with_stats.rs
Expand Up @@ -3,7 +3,7 @@

use std::{
cmp,
cmp::{Ord, Ordering},
cmp::Ordering,
convert::{TryFrom, TryInto},
fmt,
fmt::{Display, Formatter},
Expand Down Expand Up @@ -375,8 +375,6 @@ impl PartialEq for PeerAddressSource {
}
#[cfg(test)]
mod test {
use std::time::Duration;

use super::*;

#[test]
Expand Down
2 changes: 0 additions & 2 deletions comms/core/src/net_address/mutliaddresses_with_stats.rs
Expand Up @@ -291,8 +291,6 @@ impl Display for MultiaddressesWithStats {

#[cfg(test)]
mod test {
use multiaddr::Multiaddr;

use super::*;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/noise/config.rs
Expand Up @@ -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};

Expand Down
2 changes: 0 additions & 2 deletions comms/core/src/noise/socket.rs
Expand Up @@ -662,8 +662,6 @@ impl From<TransportState> for NoiseState {

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

use futures::future::join;
use snow::{params::NoiseParams, Builder, Error, Keypair};

Expand Down
8 changes: 0 additions & 8 deletions comms/core/src/peer_manager/manager.rs
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions comms/core/src/peer_manager/node_id.rs
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion comms/core/src/peer_manager/peer.rs
Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions comms/core/src/peer_manager/peer_query.rs
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/peer_manager/peer_storage.rs
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion comms/core/src/peer_validator/helpers.rs
Expand Up @@ -200,7 +200,6 @@ mod test {
use multiaddr::multiaddr;

use super::*;
use crate::peer_validator::error::PeerValidatorError;

#[test]
fn validate_address_strict() {
Expand Down
3 changes: 0 additions & 3 deletions comms/core/src/pipeline/inbound.rs
Expand Up @@ -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::*;
Expand Down
4 changes: 1 addition & 3 deletions comms/core/src/pipeline/outbound.rs
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/tor/control_client/client.rs
Expand Up @@ -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;
Expand Down

0 comments on commit 5434608

Please sign in to comment.