Files
ruvnet--RuView/v2/crates/wifi-densepose-bfld/tests/frame_header_size.rs
T
ruv c965e3e6c0 feat(adr-118/p1): scaffold wifi-densepose-bfld crate + frame header (3/3 tests GREEN)
Land P1 of the BFLD rollout — the wire-format primitives:

- New workspace member: v2/crates/wifi-densepose-bfld
- PrivacyClass enum (Raw/Derived/Anonymous/Restricted) with allows_network()
  and allows_matter() const helpers reflecting ADR-120 §2.2 and ADR-122 §2.4
- BfldFrameHeader (#[repr(C, packed)]) per ADR-119 §2.1
- BFLD_MAGIC = 0xBF1D_0001, BFLD_VERSION = 1
- BfldError variants for InvalidMagic / UnsupportedVersion / Crc / PrivacyViolation
- soul-signature cargo feature (gated, default OFF) per ADR-118 §1.4
- Compile-time size assertion via static_assertions::const_assert_eq!
- 3 acceptance tests in tests/frame_header_size.rs (all pass)

Bug fix:
- ADR-119 AC1 claimed BfldFrameHeader is 40 bytes. Actual packed layout sums
  to 86 bytes. Updated AC1 and §2.1 prose to match. const_assert in frame.rs
  pins the value structurally — a future field addition that breaks the size
  fails to compile.

Out of scope for this iter (deferred to later P1 commits):
- Field-level missing-docs warnings (21) — addressed alongside accessor helpers
- Payload section parsing — needs the section-length prefix tests
- Round-trip serialize/parse — covered by a fixture-based test in the next iter

cargo test -p wifi-densepose-bfld --no-default-features → 3 passed, 0 failed

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-24 13:34:05 -04:00

29 lines
918 B
Rust

//! Acceptance test ADR-119 AC1: `BfldFrameHeader` size is platform-stable.
//!
//! The static assertion in `frame.rs` already enforces this at compile time on
//! the local target. This runtime test exists so CI surfaces the failure with
//! a useful message rather than a `const_assert_eq!` link error.
use wifi_densepose_bfld::{BfldFrameHeader, BFLD_HEADER_SIZE, BFLD_MAGIC, BFLD_VERSION};
#[test]
fn header_size_is_86_bytes() {
assert_eq!(
core::mem::size_of::<BfldFrameHeader>(),
BFLD_HEADER_SIZE,
"BfldFrameHeader must be exactly {BFLD_HEADER_SIZE} bytes (packed)",
);
}
#[test]
fn magic_reads_as_bfld_in_hex() {
// 0xBF1D_0001 — "BF1D" looks like "BFLD" in xxd output; final 0001 is the
// major version that lives in the dedicated `version` field as well.
assert_eq!(BFLD_MAGIC, 0xBF1D_0001);
}
#[test]
fn version_is_one() {
assert_eq!(BFLD_VERSION, 1);
}