Commit fb3b8b84 authored by daniel.eades's avatar daniel.eades
Browse files

fix/silence clippy lints in test modules

parent 9cf1fa36
......@@ -114,6 +114,7 @@ fn base_dirs() -> Result<&'static BaseDirs, Error> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
......
......@@ -581,6 +581,7 @@ impl<'a> Display for DiffResult<'a> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
......
......@@ -414,6 +414,7 @@ fn get_decoder<'a, S: AsyncBufRead + Unpin + Send + 'a>(
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use tor_rtmock::{io::stream_pair, time::MockSleepProvider};
......@@ -601,7 +602,7 @@ mod test {
assert!(request[..].starts_with(b"GET /tor/server/all.z HTTP/1.0\r\n"));
assert_eq!(response.status_code(), 200);
assert_eq!(response.is_partial(), false);
assert!(!response.is_partial());
assert!(response.error().is_none());
assert!(response.source().is_none());
let out = response.into_output();
......
......@@ -410,7 +410,7 @@ fn add_common_headers(req: http::request::Builder) -> http::request::Builder {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
......
......@@ -18,6 +18,7 @@ pub(crate) fn encode_request(req: &http::Request<()>) -> String {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
......
......@@ -122,6 +122,7 @@ impl AuthorityBuilder {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn authority() {
......@@ -136,14 +137,14 @@ mod test {
assert_eq!(auth.v3ident(), &key1);
let keyids1 = AuthCertKeyIds {
id_fingerprint: key1.clone(),
sk_fingerprint: key2.clone(),
id_fingerprint: key1,
sk_fingerprint: key2,
};
assert!(auth.matches_keyid(&keyids1));
let keyids2 = AuthCertKeyIds {
id_fingerprint: key2.clone(),
sk_fingerprint: key2.clone(),
id_fingerprint: key2,
sk_fingerprint: key2,
};
assert!(!auth.matches_keyid(&keyids2));
}
......
......@@ -489,6 +489,7 @@ mod fallbacks {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use tempfile::tempdir;
......
......@@ -98,6 +98,7 @@ impl<T> SharedMutArc<T> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn shared_mut_arc() {
......
......@@ -130,6 +130,7 @@ impl From<Vec<u8>> for InputString {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use tempfile::tempdir;
......
......@@ -916,6 +916,7 @@ const DROP_OLD_CONSENSUSES: &str = "
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use hex_literal::hex;
use tempfile::{tempdir, TempDir};
......@@ -1151,11 +1152,11 @@ mod test {
sk_fingerprint: [3; 20].into(),
};
let m1 = AuthCertMeta::new(keyids.clone(), now.into(), (now + one_hour * 24).into());
let m1 = AuthCertMeta::new(keyids, now.into(), (now + one_hour * 24).into());
store.store_authcerts(&[(m1, "Pretend this is a cert")])?;
let certs = store.authcerts(&[keyids.clone(), keyids2])?;
let certs = store.authcerts(&[keyids, keyids2])?;
assert_eq!(certs.len(), 1);
assert_eq!(certs.get(&keyids).unwrap(), "Pretend this is a cert");
......
......@@ -151,6 +151,7 @@ impl LinkSpec {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use hex_literal::hex;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
......
......@@ -122,6 +122,7 @@ impl CircTarget for OwnedCircTarget {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn targetinfo() {
......
......@@ -59,6 +59,7 @@ pub trait CircTarget: ChanTarget {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use hex_literal::hex;
use std::net::IpAddr;
......
......@@ -67,6 +67,7 @@ pub fn validate_all_sigs(v: &[Box<dyn ValidatableSignature>]) -> bool {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
#[test]
fn validatable_ed_sig() {
use super::ed25519::{PublicKey, Signature, ValidatableEd25519Signature};
......
......@@ -157,6 +157,7 @@ pub fn blind_pubkey(pk: &PublicKey, mut param: [u8; 32]) -> Result<PublicKey, Bl
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
use std::convert::TryInto;
......
......@@ -78,6 +78,7 @@ impl<'a> Asn1<'a> {
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
// A cert generated by chutney
const CHUTNEY_CERT: &[u8] = include_bytes!("../testdata/tor.der");
// current (Sep 2020) certificate for www.torproject.org
......
......@@ -683,6 +683,7 @@ impl<'a> tor_linkspec::CircTarget for Relay<'a> {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::testnet::*;
use std::collections::HashSet;
......@@ -707,7 +708,7 @@ mod test {
// No microdescriptors, so we don't have enough paths, and can't
// advance.
assert_eq!(dir.have_enough_paths(), false);
assert!(!dir.have_enough_paths());
let mut dir = match dir.unwrap_if_sufficient() {
Ok(_) => panic!(),
Err(d) => d,
......@@ -990,7 +991,7 @@ mod test {
// exits to 443 on IPv6.
use tor_netdoc::doc::netstatus::RelayFlags;
let netdir = construct_custom_netdir(|idx, nb| {
if 10 <= idx && idx < 20 {
if (10..20).contains(&idx) {
nb.rs.add_flags(RelayFlags::BAD_EXIT);
}
nb.md.parse_ipv6_policy("accept 443").unwrap();
......
......@@ -345,6 +345,6 @@ mod test {
assert_eq!(p.bw_weight_scale.get(), 70);
assert_eq!(p.min_circuit_path_threshold.as_percent().get(), 45);
let b_val: bool = p.extend_by_ed25519_id.into();
assert_eq!(b_val, true);
assert!(b_val);
}
}
......@@ -75,6 +75,7 @@ where
#[cfg(test)]
pub(crate) mod test {
#![allow(clippy::unwrap_used)]
use super::*;
#[cfg(not(feature = "stochastic_tests"))]
......
......@@ -378,6 +378,7 @@ fn log2_upper(n: u64) -> u32 {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use netstatus::RelayWeight as RW;
use std::net::SocketAddr;
......
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