Commit 1e970af0 authored by daniel.eades's avatar daniel.eades
Browse files

fix/silence clippy lints in test modules

parent 9cf1fa36
Pipeline #12463 passed with stage
in 3 minutes and 40 seconds
......@@ -284,6 +284,7 @@ mod u8_array_impls {
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use crate::{Reader, Writer};
use hex_literal::hex;
macro_rules! check_encode {
......@@ -333,7 +334,7 @@ mod tests {
#[test]
fn roundtrip_u64() {
check_roundtrip!(u64, 0x4040111u64, [0, 0, 0, 0, 4, 4, 1, 17]);
check_roundtrip!(u64, 0x4040111_u64, [0, 0, 0, 0, 4, 4, 1, 17]);
}
#[test]
......
......@@ -269,6 +269,7 @@ impl<'a> Reader<'a> {
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn bytecursor_read_ok() {
......
......@@ -352,7 +352,7 @@ fn test_relay() {
// Try converting to/from raw bodies.
let body = [3_u8; 509];
let cell = msg::Relay::from_raw(body.clone());
let cell = msg::Relay::from_raw(body);
let body2 = cell.into_relay_body();
assert_eq!(&body2[..], &body[..]);
}
......
......@@ -21,7 +21,7 @@ fn unhex(s: &str) -> Vec<u8> {
}
fn decode(cmd: RelayCmd, body: &[u8]) -> Result<msg::RelayMsg, BytesError> {
let mut r = tor_bytes::Reader::from_slice(&body[..]);
let mut r = tor_bytes::Reader::from_slice(body);
msg::RelayMsg::decode_from_reader(cmd, &mut r)
}
......
......@@ -618,6 +618,7 @@ impl tor_checkable::Timebound<Ed25519Cert> for SigCheckedCert {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use hex_literal::hex;
......
......@@ -108,6 +108,7 @@ impl crate::mgr::AbstractChannel for tor_proto::channel::Channel {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::{
mgr::{AbstractChannel, ChannelFactory},
......
......@@ -232,6 +232,7 @@ impl<CF: ChannelFactory> AbstractChanMgr<CF> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::Error;
......
......@@ -180,6 +180,7 @@ impl<C: AbstractChannel> ChannelMap<C> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[derive(Eq, PartialEq, Debug)]
struct FakeChannel {
......
......@@ -37,6 +37,7 @@ impl<T> super::SelfSigned<T> for SignatureGated<T> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::SelfSigned;
use tor_llcrypto::pk::ValidatableSignature;
......
......@@ -382,6 +382,7 @@ where
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use futures::channel::oneshot;
use std::sync::atomic::{AtomicU64, Ordering::SeqCst};
......@@ -616,8 +617,8 @@ mod test {
let outcome = rt.wait_for(builder.build_owned(p1, &params, rng)).await;
let circ = outcome.unwrap().into_inner().unwrap();
assert_eq!(circ.onehop, true);
assert_eq!(circ.hops[..], [[0x11; 32].into()]);
assert!(circ.onehop);
assert_eq!(circ.hops, [[0x11; 32].into()]);
let rng =
StdRng::from_rng(rand::thread_rng()).expect("couldn't construct temporary rng");
......@@ -625,7 +626,7 @@ mod test {
.wait_for(builder.build_owned(p2.clone(), &params, rng))
.await;
let circ = outcome.unwrap().into_inner().unwrap();
assert_eq!(circ.onehop, false);
assert!(!circ.onehop);
assert_eq!(
circ.hops[..],
[[0x11; 32].into(), [0x22; 32].into(), [0x33; 32].into()]
......@@ -634,10 +635,10 @@ mod test {
{
let mut h = timeouts.lock().unwrap();
assert_eq!(h.hist.len(), 2);
assert_eq!(h.hist[0].0, true); // completed
assert!(h.hist[0].0); // completed
assert_eq!(h.hist[0].1, 0); // last hop completed
// TODO: test time elapsed, once wait_for is more reliable.
assert_eq!(h.hist[1].0, true); // completed
assert!(h.hist[1].0); // completed
assert_eq!(h.hist[1].1, 2); // last hop completed
// TODO: test time elapsed, once wait_for is more reliable.
h.hist.clear();
......@@ -657,7 +658,7 @@ mod test {
{
let mut h = timeouts.lock().unwrap();
assert_eq!(h.hist.len(), 1);
assert_eq!(h.hist[0].0, false);
assert!(!h.hist[0].0);
assert_eq!(h.hist[0].1, 2);
h.hist.clear();
}
......@@ -672,14 +673,14 @@ mod test {
assert!(outcome.is_err());
// "wait" a while longer to make sure that we eventually
// notice the circuit completing.
for _ in 0..1000u16 {
for _ in 0..1000_u16 {
rt.advance(Duration::from_millis(100)).await;
}
{
let h = timeouts.lock().unwrap();
dbg!(&h.hist);
// First we notice a circuit timeout after 2 hops
assert_eq!(h.hist[0].0, false);
assert!(!h.hist[0].0);
assert_eq!(h.hist[0].1, 2);
// TODO: check timeout more closely.
assert!(h.hist[0].2 < Duration::from_secs(100));
......@@ -690,7 +691,7 @@ mod test {
{
assert_eq!(h.hist.len(), 2);
// Then we notice a circuit completing at its third hop.
assert_eq!(h.hist[1].0, true);
assert!(h.hist[1].0);
assert_eq!(h.hist[1].1, 2);
// TODO: check timeout more closely.
assert!(h.hist[1].2 < Duration::from_secs(100));
......
......@@ -316,6 +316,7 @@ async fn continually_expire_circuits<R: Runtime>(runtime: R, circmgr: Weak<CircM
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
......@@ -326,7 +327,7 @@ mod test {
let di: DirInfo<'_> = (&[][..]).into();
let p1 = di.circ_params();
assert_eq!(p1.extend_by_ed25519_id(), false);
assert!(!p1.extend_by_ed25519_id());
assert_eq!(p1.initial_send_window(), 1000);
// Now try with a directory and configured parameters.
......@@ -342,7 +343,7 @@ mod test {
let di: DirInfo<'_> = (&netdir).into();
let p2 = di.circ_params();
assert_eq!(p2.initial_send_window(), 100);
assert_eq!(p2.extend_by_ed25519_id(), true);
assert!(p2.extend_by_ed25519_id());
// Now try with a bogus circwindow value.
let (consensus, microdescs) = tor_netdir::testnet::construct_network().unwrap();
......@@ -357,6 +358,6 @@ mod test {
let di: DirInfo<'_> = (&netdir).into();
let p2 = di.circ_params();
assert_eq!(p2.initial_send_window(), 1000); // Not 100_000
assert_eq!(p2.extend_by_ed25519_id(), true);
assert!(p2.extend_by_ed25519_id());
}
}
......@@ -1104,6 +1104,7 @@ impl<B: AbstractCircBuilder + 'static, R: Runtime> AbstractCircMgr<B, R> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::Error;
use std::collections::BTreeSet;
......
......@@ -115,6 +115,7 @@ where
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use futures_await_test::async_test;
......
......@@ -127,6 +127,7 @@ impl OwnedPath {
/// path.
#[cfg(test)]
fn assert_same_path_when_owned(path: &TorPath<'_>) {
#![allow(clippy::unwrap_used)]
use std::convert::TryInto;
use tor_linkspec::ChanTarget;
let owned: OwnedPath = path.try_into().unwrap();
......
......@@ -47,6 +47,7 @@ impl DirPathBuilder {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::path::assert_same_path_when_owned;
use tor_netdir::fallback::FallbackDir;
......
......@@ -139,6 +139,7 @@ fn relays_can_share_circuit(a: &Relay<'_>, b: &Relay<'_>, subnet_config: &Subnet
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::path::{assert_same_path_when_owned, OwnedPath, TorPathInner};
use std::convert::TryInto;
......
......@@ -655,6 +655,7 @@ impl ParetoEstimatorInner {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::timeouts::TimeoutEstimator;
......@@ -671,6 +672,7 @@ mod test {
#[test]
fn ms_partial_cmp() {
#![allow(clippy::eq_op)]
let myriad: MsecDuration = 10_000.into();
let lakh: MsecDuration = 100_000.into();
let crore: MsecDuration = 10_000_000.into();
......
......@@ -262,6 +262,7 @@ impl crate::mgr::AbstractSpec for SupportedCircUsage {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use tor_netdir::testnet;
......
#![allow(clippy::unwrap_used)]
//! Implement a configuration source based on command-line arguments.
use config::{ConfigError, Source, Value};
......@@ -127,6 +128,7 @@ fn tweak_toml_bareword(s: &str) -> Option<String> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn bareword_expansion() {
......
......@@ -104,6 +104,7 @@ pub fn default_config_file() -> Option<PathBuf> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use tempfile::tempdir;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment