Skip to content

Commit eb60061

Browse files
committed
test(iroh-relay): integration tests for embedding the relay
Adds two integration tests that demonstrate embedding the relay inside an external HTTP server, one with axum and one with hyper.
1 parent d636e54 commit eb60061

5 files changed

Lines changed: 439 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 76 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-relay/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ tokio = { version = "1", features = [
121121
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
122122
serde_json = "1"
123123
n0-tracing-test = "0.3"
124+
# Used by the embedding integration tests.
125+
axum = { version = "0.8", features = ["ws"] }
124126

125127
[build-dependencies]
126128
cfg_aliases = "0.2.1"

iroh-relay/src/server/http_server.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ use crate::{
5252
},
5353
};
5454

55-
// type BytesBody = http_body_util::Full<hyper::body::Bytes>;
56-
pub(super) type BytesBody = Box<
55+
/// Boxed HTTP response body produced by [`RelayServiceWithNotify`].
56+
pub type BytesBody = Box<
5757
dyn 'static + Send + Unpin + hyper::body::Body<Data = hyper::body::Bytes, Error = Infallible>,
5858
>;
59-
pub(super) type HyperError = Box<dyn std::error::Error + Send + Sync>;
60-
pub(super) type HyperResult<T> = std::result::Result<T, HyperError>;
59+
/// Boxed error type returned from [`RelayServiceWithNotify`]'s [`hyper::service::Service`] impl.
60+
pub type HyperError = Box<dyn std::error::Error + Send + Sync>;
61+
/// Result alias for HTTP responses produced by [`RelayServiceWithNotify`].
62+
pub type HyperResult<T> = std::result::Result<T, HyperError>;
6163
pub(super) type HyperHandler = Box<
6264
dyn Fn(Request<Incoming>, ResponseBuilder) -> HyperResult<Response<BytesBody>>
6365
+ Send

0 commit comments

Comments
 (0)