refactor(storage-server): add SectorId, FileName, PackedPath newtypes, eliminate raw primitives and DRY violations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user