test(client): cover accepted LAN destinations

The Windows TAP receive path depends on accepting relay frames that are
addressed to the client virtual MAC as well as broadcast and multicast LAN
traffic. That is what carries DHCP, ARP, and LAN discovery back into the TAP
adapter.

Add a focused client-core test for the destination classifier so unrelated
unicast stays dropped while directed, broadcast, and multicast LAN frames
continue to be accepted.

Test Plan:
- cargo fmt --check
- cargo test -p lanparty-client-core accepts_lan_destinations_for_client_tap
- cargo test -p lanparty-client-core
- cargo clippy -p lanparty-client-core --all-targets -- -D warnings
- git diff --check
- git diff --cached --check

Refs: MVP TAP receive validation
This commit is contained in:
2026-05-22 07:40:24 +02:00
parent cdc3a946a9
commit fa9265ff51
+48
View File
@@ -1066,6 +1066,37 @@ mod tests {
assert_eq!(snapshot.malformed_frames(), 1);
}
#[test]
fn accepts_lan_destinations_for_client_tap() {
let virtual_mac = MacAddr::new([0x02, 0, 0, 0, 0, 1]);
let lan_source = MacAddr::new([0x0a, 0, 0, 0, 0, 2]);
assert!(accepted_relay_destination(
virtual_mac,
lan_source,
virtual_mac,
b"directed",
));
assert!(accepted_relay_destination(
MacAddr::BROADCAST,
lan_source,
virtual_mac,
b"broadcast",
));
assert!(accepted_relay_destination(
MacAddr::new([0x01, 0x00, 0x5e, 0, 0, 1]),
lan_source,
virtual_mac,
b"multicast",
));
assert!(!accepted_relay_destination(
MacAddr::new([0x02, 0, 0, 0, 0, 9]),
lan_source,
virtual_mac,
b"wrong client",
));
}
#[test]
fn converts_relay_rtt_to_milliseconds() {
assert_eq!(duration_millis_saturating(Duration::from_micros(999)), 0);
@@ -1168,6 +1199,23 @@ mod tests {
frame
}
fn accepted_relay_destination(
destination: MacAddr,
source: MacAddr,
virtual_mac: MacAddr,
payload: &[u8],
) -> bool {
let bytes = ethernet_frame_with_headers(
destination,
source,
lanparty_proto::ETHERTYPE_IPV4,
payload,
);
let frame = EthernetFrame::parse(&bytes).unwrap();
is_accepted_relay_destination(frame, virtual_mac)
}
fn unique_temp_identity_path() -> std::path::PathBuf {
let nanos = SystemTime::now()
.duration_since(UNIX_EPOCH)