refactor(storage-server): add SectorId, FileName, PackedPath newtypes, eliminate raw primitives and DRY violations

This commit is contained in:
2026-10-18 03:41:14 +02:00
parent 7a4600b3a2
commit 2dc503e07e
8 changed files with 162 additions and 111 deletions

View File

@@ -4,7 +4,8 @@ use server_framework::{Decode, Encode};
#[test]
fn open_roundtrip() {
let req = StorageRequest::Open { path_word0: 0x61626364, path_word1: 0 };
let path = PackedPath::from_bytes(b"test.txt");
let req = StorageRequest::Open { path };
assert_eq!(StorageRequest::decode(req.encode()), Some(req));
}
@@ -62,3 +63,11 @@ fn all_response_variants() {
fn invalid_request_returns_none() {
assert!(StorageRequest::decode([99, 0, 0, 0]).is_none());
}
#[test]
fn packed_path_roundtrip() {
let path = PackedPath::from_bytes(b"hello");
let buf = path.to_bytes();
assert_eq!(&buf[..5], b"hello");
assert_eq!(buf[5], 0);
}