Skip to content

Commit

Permalink
src: tests: Add checksum error while deconding test
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Apr 3, 2024
1 parent a920585 commit 6d2eb01
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ fn test_simple_deserialization() {
panic!("Failed to use decoder with valid message");
};

// Retry with a wrong receipt CRC
for byte in &buffer[0..buffer.len() - 2] {
dbg!(byte, &decoder.state);
assert!(matches!(
decoder.parse_byte(byte.clone()),
DecoderResult::InProgress
));
}
assert!(matches!(
decoder.parse_byte(buffer[buffer.len() - 2]),
DecoderResult::InProgress
));
assert!(matches!(
decoder.parse_byte(0x01), // force a crc error
DecoderResult::Error(ParseError::ChecksumError)
));

// Wrong CRC test
let buffer: Vec<u8> = vec![
0x42, 0x52, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x05, 0x00, 0xa1, 0x01,
Expand Down

0 comments on commit 6d2eb01

Please sign in to comment.