refactor(core): co-locate the quic wire tests with their modules
quic/tests.rs (1813 lines, 43 tests) was the W7 split's leftover: the source moved into handshake/caps/control/clock/pairing/pake/datagram/ endpoint/clipstream/io but every test stayed in one monolithic file. Each test now lives in a #[cfg(test)] mod tests at the foot of the module it exercises, verbatim. The two CompositorPref/GamepadPref wire/name tests moved to config.rs (where those enums live), so they now also run under --no-default-features. The clip_loopback and ctrl_framing integration mods share connect_pair via a cfg(test)-only quic/test_util.rs. Test-only motion: 196 lib tests pass unchanged on macOS, clippy --features quic --all-targets clean, include/punktfunk_core.h byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -171,3 +171,34 @@ impl PairResult {
|
||||
Ok(PairResult { ok: b[5] != 0 })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::quic::*;
|
||||
|
||||
#[test]
|
||||
fn pair_messages_roundtrip() {
|
||||
let pr = PairRequest {
|
||||
name: "Enrico's Mac".into(),
|
||||
spake_a: vec![1, 2, 3, 4, 5],
|
||||
};
|
||||
assert_eq!(PairRequest::decode(&pr.encode()).unwrap(), pr);
|
||||
let pc = PairChallenge {
|
||||
spake_b: vec![9; 33],
|
||||
confirm: [7u8; 32],
|
||||
};
|
||||
assert_eq!(PairChallenge::decode(&pc.encode()).unwrap(), pc);
|
||||
let pp = PairProof { confirm: [3u8; 32] };
|
||||
assert_eq!(PairProof::decode(&pp.encode()).unwrap(), pp);
|
||||
for ok in [true, false] {
|
||||
assert_eq!(
|
||||
PairResult::decode(&PairResult { ok }.encode()).unwrap().ok,
|
||||
ok
|
||||
);
|
||||
}
|
||||
// Length-exact: a truncated/padded PairProof is rejected.
|
||||
let mut bad = pp.encode();
|
||||
bad.push(0);
|
||||
assert!(PairProof::decode(&bad).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user