diff --git a/tests/deserialize.rs b/tests/deserialize.rs index d977d4c3b..55d0c0297 100644 --- a/tests/deserialize.rs +++ b/tests/deserialize.rs @@ -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 = vec![ 0x42, 0x52, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x05, 0x00, 0xa1, 0x01,