| 136 | |
| 137 | #[test] |
| 138 | fn header_rejects_v2_segment() { |
| 139 | let mut buf = Vec::new(); |
| 140 | buf.extend_from_slice(&HEADER_MAGIC); |
| 141 | buf.extend_from_slice(&2u16.to_le_bytes()); |
| 142 | buf.extend_from_slice(&0u16.to_le_bytes()); |
| 143 | buf.extend_from_slice(&0u64.to_le_bytes()); |
| 144 | let crc = crc32c::crc32c(&buf[..20]); |
| 145 | buf.extend_from_slice(&crc.to_le_bytes()); |
| 146 | let err = SegmentHeader::decode(&buf).unwrap_err(); |
| 147 | assert!( |
| 148 | matches!( |
| 149 | err, |
| 150 | crate::error::ArrayError::UnsupportedSegmentFormat { version: 2 } |
| 151 | ), |
| 152 | "expected UnsupportedSegmentFormat {{version: 2}}, got {err:?}" |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | /// Asserts 8-byte magic, FORMAT_VERSION == 1 at bytes [8..10], and CRC at [20..24]. |
| 157 | #[test] |