address some possibly slightly controversial lints

This commit is contained in:
Daniel Eades 2021-07-21 07:27:26 +01:00
parent d23256074e
commit ed14a7fcf2
5 changed files with 12 additions and 18 deletions

View File

@ -14,9 +14,7 @@ impl rand::RngCore for BadRng {
0xf0f0f0f0f0f0f0f0
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
for i in 0..dest.len() {
dest[i] = 0xf0;
}
dest.fill(0xf0);
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
self.fill_bytes(dest);

View File

@ -457,7 +457,7 @@ mod test {
rt.sleep(Duration::from_millis(HOP1_DELAY.load(SeqCst)))
.await;
let c = FakeCirc {
hops: vec![ct.ed_identity().clone()],
hops: vec![*ct.ed_identity()],
onehop: true,
};
Ok(Mutex::new(c))
@ -472,7 +472,7 @@ mod test {
rt.sleep(Duration::from_millis(HOP1_DELAY.load(SeqCst)))
.await;
let c = FakeCirc {
hops: vec![ct.ed_identity().clone()],
hops: vec![*ct.ed_identity()],
onehop: false,
};
Ok(Mutex::new(c))
@ -496,7 +496,7 @@ mod test {
rt.sleep(Duration::from_millis(d)).await;
{
let mut c = self.lock().unwrap();
c.hops.push(ct.ed_identity().clone());
c.hops.push(*ct.ed_identity());
}
Ok(())
}

View File

@ -1360,12 +1360,11 @@ mod test {
))
.await;
if c2.is_ok() {
let c1 = c1.unwrap();
let c2 = c2.unwrap();
if let (Ok(c1), Ok(c2)) = (c1, c2) {
assert!(Arc::ptr_eq(&c1, &c2));
return;
}
} else {
panic!()
};
});
}

View File

@ -83,7 +83,7 @@ mod test {
use tor_linkspec::ChanTarget;
use tor_netdir::testnet;
fn assert_exit_path_ok<'a>(relays: &[Relay<'a>]) {
fn assert_exit_path_ok(relays: &[Relay]) {
assert_eq!(relays.len(), 3);
// TODO: Eventually assert that r1 has Guard, once we enforce that.

View File

@ -757,12 +757,9 @@ mod test {
picked[id_byte as usize] += 1;
}
// non-exits should never get picked.
for idx in 0..10 {
assert_eq!(picked[idx], 0);
}
for idx in 20..30 {
assert_eq!(picked[idx], 0);
}
picked[0..10].iter().for_each(|x| assert_eq!(*x, 0));
picked[20..30].iter().for_each(|x| assert_eq!(*x, 0));
// We didn't we any non-default weights, so the other relays get
// weighted proportional to their bandwidth.
check_close(picked[19], (total * 10) / 110);