use crate::stream::{recv, recv::buffer::Dispatch};
use std::net::{IpAddr, Ipv4Addr};
#[test]
fn check_truncation() {
let mut local = super::Local::new(super::msg::recv::Message::new(9000), None);
let mut dispatch = NoopDispatch;
let packet = vec![0b0101_0000];
local.recv_buffer.test_recv(
(IpAddr::from(Ipv4Addr::LOCALHOST), 1).into(),
Default::default(),
packet,
);
local.dispatch_buffer_stream(&mut dispatch).unwrap();
local.saw_fin = true;
let err = local.dispatch_buffer_stream(&mut dispatch).unwrap_err();
assert!(matches!(err.kind(), recv::error::Kind::Decode));
}
struct NoopDispatch;
impl Dispatch for NoopDispatch {
fn on_packet(
&mut self,
_remote_addr: &s2n_quic_core::inet::SocketAddress,
_ecn: s2n_quic_core::inet::ExplicitCongestionNotification,
_packet: crate::packet::Packet,
) -> Result<(), crate::stream::recv::Error> {
unreachable!()
}
}