Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions crates/protocol/src/codec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,8 @@ mod tests {
let codecs = ProtocolCodecs::for_version(32);
let mut buf = Vec::new();

// Write file size
codecs.wire.write_file_size(&mut buf, 12345).unwrap();

// Read it back
let mut cursor = Cursor::new(&buf);
let value = codecs.wire.read_file_size(&mut cursor).unwrap();
assert_eq!(value, 12345);
Expand All @@ -234,12 +232,11 @@ mod tests {
let mut codecs = ProtocolCodecs::for_version(32);
let mut buf = Vec::new();

// Write NDX values
codecs.ndx.write_ndx(&mut buf, 0).unwrap();
codecs.ndx.write_ndx(&mut buf, 1).unwrap();
codecs.ndx.write_ndx(&mut buf, 5).unwrap();

// Read them back with fresh codec state
// Fresh codec state on the reader side: NDX deltas are stateful.
let mut read_codecs = ProtocolCodecs::for_version(32);
let mut cursor = Cursor::new(&buf);
assert_eq!(read_codecs.ndx.read_ndx(&mut cursor).unwrap(), 0);
Expand All @@ -254,13 +251,11 @@ mod tests {
let mut codecs = ProtocolCodecs::for_version(30);
let mut buf = Vec::new();

// Mix wire and NDX operations
codecs.wire.write_file_size(&mut buf, 1000).unwrap();
codecs.ndx.write_ndx(&mut buf, 0).unwrap();
codecs.wire.write_mtime(&mut buf, 1700000000).unwrap();
codecs.ndx.write_ndx(&mut buf, 1).unwrap();

// Read them back
let mut read_codecs = ProtocolCodecs::for_version(30);
let mut cursor = Cursor::new(&buf);

Expand Down
1 change: 0 additions & 1 deletion crates/protocol/src/flist/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ mod tests {

#[test]
fn flags_from_u32() {
// Test with all three bytes
let value: u32 = 0x020103; // extended16=0x02, extended=0x01, primary=0x03
let flags = FileFlags::from_u32(value);
assert_eq!(flags.primary, 0x03);
Expand Down
8 changes: 3 additions & 5 deletions crates/protocol/src/flist/write/tests/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ fn zero_flags_varint_uses_xmit_extended_flags() {
.update(b"prefix/", 0o100644, 1700000000, 1000, 1000);

let mut entry = FileEntry::new_file("prefix/file.txt".into(), 100, 0o644);
entry.set_mtime(1700000000, 0); // Same time
entry.set_uid(1000); // Same UID
entry.set_gid(1000); // Same GID
entry.set_mtime(1700000000, 0);
entry.set_uid(1000);
entry.set_gid(1000);

let mut buf = Vec::new();
writer.write_entry(&mut buf, &entry).unwrap();

// Decode the first varint to check the flags value
let (flags_value, _) = decode_varint(&buf).unwrap();

// Should NOT be 0 (end marker), should be XMIT_EXTENDED_FLAGS (0x04)
assert_ne!(flags_value, 0, "flags should not be zero (end marker)");
assert!(
(flags_value as u32) & (XMIT_EXTENDED_FLAGS as u32) != 0
Expand Down
1 change: 0 additions & 1 deletion crates/protocol/src/flist/write/tests/hardlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ fn hardlink_round_trip_with_interspersed_directories() {
writer.write_entry(&mut buf, &follower).unwrap();
writer.write_end(&mut buf, None).unwrap();

// Read back
let mut cursor = Cursor::new(&buf[..]);
let mut reader = FileListReader::new(protocol).with_preserve_hard_links(true);

Expand Down
3 changes: 0 additions & 3 deletions crates/protocol/src/wire/compressed_token/lz4_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ mod tests {
block_sizes.iter().sum::<usize>(),
);

// Verify roundtrip
let mut decoder = Lz4TokenDecoder::new();
let mut read_cursor = Cursor::new(&encoded);
let mut result = Vec::new();
Expand Down Expand Up @@ -688,7 +687,6 @@ mod tests {
"block match without literals should not produce DEFLATED_DATA"
);

// Verify roundtrip
let mut decoder = Lz4TokenDecoder::new();
let mut cursor = Cursor::new(&encoded);
let mut blocks = Vec::new();
Expand Down Expand Up @@ -928,7 +926,6 @@ mod tests {

encoder.finish(&mut encoded).unwrap();

// Verify roundtrip
let expected: Vec<u8> = vec![b'X'; 65536 * 4];
let mut decoder = Lz4TokenDecoder::new();
let mut cursor = Cursor::new(&encoded);
Expand Down
2 changes: 0 additions & 2 deletions crates/protocol/src/wire/compressed_token/zstd_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,6 @@ mod tests {
block_sizes.iter().sum::<usize>(),
);

// Verify roundtrip
let mut decoder = ZstdTokenDecoder::new().unwrap();
let mut read_cursor = Cursor::new(&encoded);
let mut result = Vec::new();
Expand Down Expand Up @@ -870,7 +869,6 @@ mod tests {
"block match without literals should not produce DEFLATED_DATA"
);

// Verify roundtrip
let mut decoder = ZstdTokenDecoder::new().unwrap();
let mut cursor = Cursor::new(&encoded);
let mut blocks = Vec::new();
Expand Down
2 changes: 0 additions & 2 deletions crates/protocol/src/wire/vectored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ mod tests {

let written = write_vectored_all(&mut writer, &buffer_refs).expect("large write succeeds");

// Verify all data was written
let mut expected = Vec::new();
for d in &data {
expected.extend_from_slice(d);
Expand Down Expand Up @@ -337,7 +336,6 @@ mod tests {
let written =
write_vectored_all(&mut writer, &buffer_refs).expect("large IOV write succeeds");

// Verify all data was written
let mut expected = Vec::new();
for d in &data {
expected.extend_from_slice(d);
Expand Down
Loading