Added test for the SACK chunk being followed
@@ -721,3 +721,33 @@ fn test_forward_tsn_chunk() -> Result<()> {
Ok(())
}
+
+#[test]
+fn test_select_ack_chunk_followed_by_a_payload_data_chunk() -> Result<()> {
+ let raw_pkt = Bytes::from_static(&[
+ 0x13, 0x88, 0x13, 0x88, 0xc2, 0x98, 0x98, 0x0f, 0x58, 0xcf, 0x38,
+ 0xC0, // A SACK chunk follows.
+ 0x03, 0x00, 0x00, 0x14, 0x87, 0x73, 0xbd, 0xa4, 0x00, 0x01, 0xfe, 0x74, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x02, // A payload data chunk follows.
+ 0x00, 0x07, 0x00, 0x3B, 0xA4, 0x50, 0x7B, 0xC5, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x33, 0x7B, 0x22, 0x65, 0x76, 0x65, 0x6E, 0x74, 0x22, 0x3A, 0x22, 0x72, 0x65, 0x73, 0x69,
+ 0x7A, 0x65, 0x22, 0x2C, 0x22, 0x77, 0x69, 0x64, 0x74, 0x68, 0x22, 0x3A, 0x36, 0x36, 0x35,
+ 0x2C, 0x22, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x3A, 0x34, 0x39, 0x39, 0x7D, 0x00,
+ ]);
+ let pkt = Packet::unmarshal(&raw_pkt)?;
+ assert!(
+ pkt.chunks[0]
+ .as_any()
+ .downcast_ref::<ChunkSelectiveAck>()
+ .is_some(),
+ "Failed to cast Chunk -> SelectiveAck"
+ );
+ assert!(
+ pkt.chunks[1]
+ .as_any()
+ .downcast_ref::<ChunkPayloadData>()
+ .is_some(),
+ "Failed to cast Chunk -> PayloadData"
+ );
+ Ok(())
+}
