mirror of
https://github.com/zerotier/zssp.git
synced 2026-05-22 16:28:40 -07:00
cargo clippy
This commit is contained in:
@@ -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,
|
||||
&[],
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
(),
|
||||
&[],
|
||||
);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user