MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / header_rejects_v2_segment

Function header_rejects_v2_segment

nodedb-array/src/segment/format/header.rs:138–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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]

Callers

nothing calls this directly

Calls 1

decodeFunction · 0.50

Tested by

no test coverage detected