[domistream] Tests: properties cannot pass against Unimplemented
The never-panic properties (XML, RTSP, ENet, control, input, media) and the allocation-cap checks only asserted inside `if let Ok`, so a stub returning Unimplemented for everything passed them. Each now also requires the parser to answer something other than Unimplemented (common::implemented); the XML truncation property wants Malformed or Truncated, not any error.
This commit is contained in:
@@ -345,25 +345,31 @@ proptest! {
|
||||
|
||||
#[test]
|
||||
fn media_parsers_never_panic(data in proptest::collection::vec(any::<u8>(), 0..200)) {
|
||||
if let Ok(h) = parse_rtp_header(&data) {
|
||||
let rtp = parse_rtp_header(&data);
|
||||
let video = parse_video_packet(&data);
|
||||
let frame = parse_frame_header(&data);
|
||||
let audio = parse_audio_packet(&data);
|
||||
prop_assert!(common::implemented(&rtp) && common::implemented(&video) && common::implemented(&frame) && common::implemented(&audio));
|
||||
if let Ok(h) = rtp {
|
||||
prop_assert!(data.len() >= RTP_HEADER_LEN);
|
||||
prop_assert_eq!(h.flags >> 6, 2);
|
||||
}
|
||||
if let Ok(p) = parse_video_packet(&data) {
|
||||
if let Ok(p) = video {
|
||||
prop_assert_eq!(p.payload.len() + PAYLOAD_OFFSET, data.len());
|
||||
prop_assert!(p.nv.fec.data_shards > 0);
|
||||
prop_assert!(p.nv.fec.block_index <= p.nv.fec.last_block_index);
|
||||
}
|
||||
if let Ok(h) = parse_frame_header(&data) {
|
||||
if let Ok(h) = frame {
|
||||
prop_assert_eq!(&h.raw[..], &data[..FRAME_HEADER_LEN]);
|
||||
}
|
||||
match parse_audio_packet(&data) {
|
||||
match audio {
|
||||
Ok(AudioPacket::Data { payload, .. }) => prop_assert!(!payload.is_empty()),
|
||||
Ok(AudioPacket::Parity { fec, parity, .. }) => prop_assert!(!parity.is_empty() && fec.shard_index <= 1),
|
||||
Err(_) => {}
|
||||
}
|
||||
let _ = VideoCipher::new([1; 16]).decrypt(&data);
|
||||
let _ = AudioCipher::new(&SessionKeys { rikey: [1; 16], rikeyid: 0 }).decrypt(0, &data);
|
||||
prop_assert!(common::implemented(&VideoCipher::new([1; 16]).decrypt(&data)));
|
||||
let audio_cipher = AudioCipher::new(&SessionKeys { rikey: [1; 16], rikeyid: 0 });
|
||||
prop_assert!(common::implemented(&audio_cipher.decrypt(0, &data)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user