test: add proto and end-to-end transfer tests
This commit is contained in:
@@ -363,8 +363,31 @@ mod tests {
|
||||
#[test]
|
||||
fn rejects_data_larger_than_512() {
|
||||
let mut bytes = vec![0, 3, 0, 1];
|
||||
bytes.extend(std::iter::repeat(0x61).take(BLOCK_SIZE + 1));
|
||||
bytes.extend(std::iter::repeat_n(0x61, BLOCK_SIZE + 1));
|
||||
let err = Packet::decode(&bytes).unwrap_err();
|
||||
assert!(matches!(err, DecodeError::OversizeData(513)));
|
||||
}
|
||||
|
||||
#[allow(clippy::unwrap_used)]
|
||||
#[test]
|
||||
fn mode_is_case_insensitive() {
|
||||
let req = Packet::decode(b"\0\x01file\0NeTaScIi\0").unwrap();
|
||||
assert!(matches!(
|
||||
req,
|
||||
Packet::Rrq(Request {
|
||||
mode: Mode::NetAscii,
|
||||
..
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
#[allow(clippy::unwrap_used)]
|
||||
#[test]
|
||||
fn error_roundtrip() {
|
||||
let pkt = Packet::Error {
|
||||
code: ErrorCode::AccessViolation,
|
||||
message: "nope".to_string(),
|
||||
};
|
||||
assert_eq!(Packet::decode(&pkt.encode()).unwrap(), pkt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user