diff --git a/hacspec/src/lib.rs b/hacspec/src/lib.rs index e6e61266..aa4644a0 100644 --- a/hacspec/src/lib.rs +++ b/hacspec/src/lib.rs @@ -1913,6 +1913,27 @@ mod tests { assert_bytes_eq!(plaintext_2.content, plaintext_2_tv.content); } + #[test] + fn test_parse_plaintext_2_invalid_traces() { + let plaintext_2_tv_len = PLAINTEXT_2_SURPLUS_MAP_ID_CRED_TV.len() / 2; + let plaintext_2_tv = BytesMaxBuffer::from_slice( + &ByteSeq::from_hex(PLAINTEXT_2_SURPLUS_MAP_ID_CRED_TV), + 0, + plaintext_2_tv_len, + ); + let plaintext_2 = decode_plaintext_2(&plaintext_2_tv, plaintext_2_tv_len); + assert!(plaintext_2.is_err()); + + let plaintext_2_tv_len = PLAINTEXT_2_SURPLUS_BSTR_ID_CRED_TV.len() / 2; + let plaintext_2_tv = BytesMaxBuffer::from_slice( + &ByteSeq::from_hex(PLAINTEXT_2_SURPLUS_BSTR_ID_CRED_TV), + 0, + plaintext_2_tv_len, + ); + let plaintext_2 = decode_plaintext_2(&plaintext_2_tv, plaintext_2_tv_len); + assert!(plaintext_2.is_err()); + } + #[test] fn test_decode_plaintext_2() { let plaintext_2_tv = BytesMaxBuffer::from_slice(