cargo clippy

This commit is contained in:
Monica Moniot
2023-11-21 15:46:33 -05:00
parent 1e34548ff1
commit c632dcf868
4 changed files with 30 additions and 32 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ fn alice_main(
alice_app,
|b: &mut [u8]| alice_out.send(b.to_vec()).is_ok(),
TEST_MTU,
bob_pubkey.clone(),
bob_pubkey,
0,
&[],
);
+1 -1
View File
@@ -136,7 +136,7 @@ fn alice_main(
alice_app,
|b: &mut [u8]| alice_out.send(alloc(b)).is_ok(),
TEST_MTU,
bob_pubkey.clone(),
bob_pubkey,
(),
&[],
);
+27 -29
View File
@@ -317,39 +317,37 @@ fn test_cache() {
assert!(assembled.is_empty(), "Cache returned an incomplete packet");
}
}
if r > 200 {
if in_progress.len() > 0 {
let to_remain = (xorshift64_random() as usize % in_progress_fragments) + 16;
while in_progress_fragments > to_remain {
let (id, fragment_count, mut packet) =
in_progress.swap_remove(xorshift64_random() as usize % in_progress.len());
for _ in 0..((xorshift64_random() as usize % packet.len()) + 1) {
let (no, fragment) = packet.swap_remove(xorshift64_random() as usize % packet.len());
if r > 200 && !in_progress.is_empty() {
let to_remain = (xorshift64_random() as usize % in_progress_fragments) + 16;
while in_progress_fragments > to_remain {
let (id, fragment_count, mut packet) =
in_progress.swap_remove(xorshift64_random() as usize % in_progress.len());
for _ in 0..((xorshift64_random() as usize % packet.len()) + 1) {
let (no, fragment) = packet.swap_remove(xorshift64_random() as usize % packet.len());
assembled.clear();
let mut nonce = [0; 12];
nonce[..4].copy_from_slice(&id.to_be_bytes());
cache.assemble(
&nonce,
0,
fragment.len(),
fragment,
no as usize,
fragment_count as usize,
time,
&mut assembled,
);
time += 200;
in_progress_fragments -= 1;
assembled.clear();
let mut nonce = [0; 12];
nonce[..4].copy_from_slice(&id.to_be_bytes());
cache.assemble(
&nonce,
0,
fragment.len(),
fragment,
no as usize,
fragment_count as usize,
time,
&mut assembled,
);
time += 200;
in_progress_fragments -= 1;
if packet.len() > 0 {
assert!(assembled.is_empty(), "Cache returned an incomplete packet");
}
}
if packet.len() > 0 {
in_progress.push((id, fragment_count, packet));
if !packet.is_empty() {
assert!(assembled.is_empty(), "Cache returned an incomplete packet");
}
}
if !packet.is_empty() {
in_progress.push((id, fragment_count, packet));
}
}
}
}
+1 -1
View File
@@ -157,7 +157,7 @@ fn alice_main(
&mut alice_app,
|b| alice_out.send(b).is_ok(),
TEST_MTU,
bob_pubkey.clone(),
bob_pubkey,
0,
Vec::new(),
)