From 7f86d40b3b5722b47e435ada53d0f7019ed5f729 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 17 Oct 2026 07:08:13 -0700 Subject: [PATCH] test(net): cover the 64 KiB cap in the default poll_read_buf Drop the transport adapter dedup quest: drop-web-transport-trait deletes the generic web_transport_trait adapters instead of sharing them. Co-Authored-By: Claude Opus 5.5 --- quest/m2/README.md | 1 - quest/m2/transport-adapter-dedup.md | 30 ----------------------- rs/moq-net/src/transport.rs | 38 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 31 deletions(-) delete mode 100644 quest/m2/transport-adapter-dedup.md diff --git a/quest/m2/README.md b/quest/m2/README.md index 8acc5a2e83d..db16f61886d 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -127,7 +127,6 @@ ranked just below deterministic TS legs, which it requires. - [Browser media report](/quest/m2/rs2ts-browser-report.md) - compare Rust-backed and handwritten @moq/net through full media workloads, supplementing the pre-adoption comparisons - [mTLS on tls://](/quest/m2/tls-listener-mtls.md) - a `tls://` listener can identify a cluster peer by its client certificate - [Link quality](/quest/m2/link-quality.md) - a radio link's cost follows its measured quality without flapping routes -- [One transport adapter](/quest/m2/transport-adapter-dedup.md) - the poll transport adapter exists once, and the 64 KiB cap in moq-net's default `poll_read_buf` (not in the adapter) has a test - [Archive S3 wire proof](/quest/m2/archive-s3.md) - the archive proof also runs through the S3 client against an in-process S3-compatible server - [Archive recovery listing](/quest/m2/archive-recovery-listing.md) - a resumed DVR lists what changed since its checkpoint, not every stored group - [IETF on the ring](/quest/m2/uring-ietf.md) - the io_uring workers serve moq-transport sessions too, so a uring relay drops no client protocol diff --git a/quest/m2/transport-adapter-dedup.md b/quest/m2/transport-adapter-dedup.md deleted file mode 100644 index 2e557dcdf2d..00000000000 --- a/quest/m2/transport-adapter-dedup.md +++ /dev/null @@ -1,30 +0,0 @@ -# [S] One copy of the poll transport adapter - -## Goal - -The poll transport adapter exists once. #4709 copied the same -~310-line adapter into `rs/moq-ffi`, `rs/moq-uring` and `rs/moq-wasm` -(`src/transport/adapter.rs`), and moq-tokio repeats its error and stats -wrappers. The 64 KiB cap on moq-net's default `poll_read_buf` has a unit test. - -## Plan - -Start from the adapter #4709 landed. The transport-seam quest ruled out a new shared adapter crate. -Revisit that here: share one copy from an existing crate (for example moq-net behind a -feature, or one backend re-exporting it to the others), or record why the -copies stay. Add the `poll_read_buf` cap test either way. - -Decided 2026-10-08: backend-specific `moq-quic` methods (`poll_acked`, -`set_deadline`, `set_limits`) stay out of the shared generic adapter; moq-tokio -and moq-uring keep their own adapter code for those. The shared copy covers -only what every backend implements the same way, so a QUIC-only seam never -forces a default onto the browser, wasm, or FFI backends. - -Public API: possibly a feature-gated module. Wire: none. - -## Related - -- [poll_acked on moq-net's send stream](/quest/m2/quic-ack-hook.md) - a backend-specific method the moq-tokio and moq-uring adapters keep -- [Per-stream deadlines](/quest/m2/quic-deadline.md) - adds `set_deadline`, also kept out of the shared adapter -- [QUIC caps](/quest/m2/rate-quic.md) - extends `set_limits` with the bitrate caps -- [Peer limits](/quest/m1/quic/peer-limits.md) - adds the `set_limits` seam diff --git a/rs/moq-net/src/transport.rs b/rs/moq-net/src/transport.rs index 8cf1ce6f551..6d0375e9203 100644 --- a/rs/moq-net/src/transport.rs +++ b/rs/moq-net/src/transport.rs @@ -712,4 +712,42 @@ mod tests { Poll::Ready(Ok(Some(0))) )); } + + #[test] + fn default_read_buf_caps_the_initialized_slice_on_ready_and_pending() { + struct ReadSpan(bool); + impl super::poll::RecvStream for ReadSpan { + type Error = crate::Error; + fn poll_read(&mut self, _: &mut Context<'_>, dst: &mut [u8]) -> Poll, Self::Error>> { + assert_eq!( + dst.len(), + 64 * 1024, + "one poll must not initialize the whole spare capacity" + ); + assert!(dst.iter().all(|byte| *byte == 0)); + if self.0 { + return Poll::Pending; + } + dst.fill(7); + Poll::Ready(Ok(Some(dst.len()))) + } + fn stop(&mut self, _: u32) {} + fn poll_closed(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Pending + } + } + for pending in [false, true] { + let mut buf = BytesMut::with_capacity(256 * 1024); + let mut cx = Context::from_waker(std::task::Waker::noop()); + let result = ReadSpan(pending).poll_read_buf(&mut cx, &mut buf); + if pending { + assert!(result.is_pending()); + assert!(buf.is_empty()); + } else { + assert!(matches!(result, Poll::Ready(Ok(Some(65536))))); + assert_eq!(buf.len(), 64 * 1024); + assert!(buf.iter().all(|byte| *byte == 7)); + } + } + } }