From 907d8cf255a1fc04772894c771670a63f3e25836 Mon Sep 17 00:00:00 2001 From: Gabriela Moldovan Date: Mon, 31 Jul 2023 01:05:58 +0100 Subject: [PATCH] tor-proto: Add TODO regarding allow_stream_requests corner case. --- crates/tor-proto/src/circuit.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/tor-proto/src/circuit.rs b/crates/tor-proto/src/circuit.rs index c22970ad4..6946277c6 100644 --- a/crates/tor-proto/src/circuit.rs +++ b/crates/tor-proto/src/circuit.rs @@ -436,6 +436,9 @@ impl ClientCirc { /// /// Only onion services (and eventually) exit relays should call this /// method. + // + // TODO HSS: this function should return an error if allow_stream_requests() + // was already called on this circuit. #[cfg(feature = "hs-service")] pub fn allow_stream_requests( self: &Arc, @@ -1837,6 +1840,27 @@ mod test { assert_eq!(p.initial_send_window(), 500); } + #[test] + // TODO HSS: allow_stream_requests() should return an error if + // the circuit already has an IncomingStream. + #[ignore] + #[cfg(feature = "hs-service")] + fn allow_stream_requests_twice() { + tor_rtcompat::test_with_all_runtimes!(|rt| async move { + let (chan, _rx, _sink) = working_fake_channel(&rt); + let (circ, _send) = newcirc(&rt, chan).await; + + let _incoming = circ + .allow_stream_requests(&[tor_cell::relaycell::RelayCmd::BEGIN]) + .unwrap(); + + let incoming = circ.allow_stream_requests(&[tor_cell::relaycell::RelayCmd::BEGIN]); + + // There can only be one IncomingStream at a time on any given circuit. + assert!(incoming.is_err()); + }); + } + #[test] #[cfg(feature = "hs-service")] fn allow_stream_requests() {