Skip to content

Commit 7b6884f

Browse files
refactor!: remove iroh-test crate (#3162)
## Description These testutils we are using, actually can be replaced through either simpler code or other crates. See the individual commits for the alternatives ## Breaking Changes - `iroh-test` crate is gone ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented.
1 parent 243a04a commit 7b6884f

38 files changed

+169
-572
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
RUSTFLAGS: -Dwarnings
2424
RUSTDOCFLAGS: -Dwarnings
2525
SCCACHE_CACHE_SIZE: "10G"
26-
CRATES_LIST: "iroh,iroh-bench,iroh-test,iroh-dns-server,iroh-relay,iroh-net-report"
26+
CRATES_LIST: "iroh,iroh-bench,iroh-dns-server,iroh-relay,iroh-net-report"
2727
IROH_FORCE_STAGING_RELAYS: "1"
2828

2929
jobs:

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ members = [
33
"iroh-base",
44
"iroh-dns-server",
55
"iroh",
6-
"iroh-test",
76
"iroh/bench",
87
"iroh-relay",
98
"iroh-net-report",

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ This repository contains a workspace of crates:
132132
- `iroh`: The core library for hole-punching & communicating with relays.
133133
- `iroh-relay`: The relay server implementation. This is the code we run in production (and you can, too!).
134134
- `iroh-base`: Common types like `Hash`, key types or `RelayUrl`.
135-
- `iroh-test`: Test utilities.
136135
- `iroh-dns-server`: DNS server implementation powering the `n0_discovery` for NodeIds, running at dns.iroh.link.
137136
- `iroh-net-report`: Analyzes your host's networking ability & NAT.
138137

iroh-base/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ thiserror = { version = "2", optional = true }
2929
getrandom = { version = "0.2", default-features = false, optional = true }
3030

3131
[dev-dependencies]
32-
iroh-test = "0.28.0"
3332
postcard = { version = "1", features = ["use-std"] }
3433
proptest = "1.0.0"
3534
rand = "0.8"

iroh-base/src/key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ fn decode_base32_hex(s: &str) -> Result<[u8; 32], KeyParsingError> {
350350

351351
#[cfg(test)]
352352
mod tests {
353-
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
353+
use data_encoding::HEXLOWER;
354354

355355
use super::*;
356356

@@ -360,10 +360,10 @@ mod tests {
360360
PublicKey::from_str("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
361361
.unwrap();
362362
let bytes = postcard::to_stdvec(&public_key).unwrap();
363-
let expected =
364-
parse_hexdump("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
365-
.unwrap();
366-
assert_eq_hex!(bytes, expected);
363+
let expected = HEXLOWER
364+
.decode(b"ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
365+
.unwrap();
366+
assert_eq!(bytes, expected);
367367
}
368368

369369
#[test]

iroh-base/src/ticket/node.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'de> Deserialize<'de> for NodeTicket {
135135
mod tests {
136136
use std::net::{Ipv4Addr, SocketAddr};
137137

138-
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
138+
use data_encoding::HEXLOWER;
139139

140140
use super::*;
141141
use crate::key::{PublicKey, SecretKey};
@@ -188,15 +188,24 @@ mod tests {
188188
.as_bytes(),
189189
)
190190
.unwrap();
191-
let expected = parse_hexdump("
192-
00 # variant
193-
ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6 # node id, 32 bytes, see above
194-
01 # relay url present
195-
10 687474703a2f2f646572702e6d652e2f # relay url, 16 bytes, see above
196-
01 # one direct address
197-
00 # ipv4
198-
7f000001 8008 # address, see above
199-
").unwrap();
200-
assert_eq_hex!(base32, expected);
191+
let expected = [
192+
// variant
193+
"00",
194+
// node id, 32 bytes, see above
195+
"ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6",
196+
// relay url present
197+
"01",
198+
// relay url, 16 bytes, see above
199+
"10",
200+
"687474703a2f2f646572702e6d652e2f",
201+
// one direct address
202+
"01",
203+
// ipv4
204+
"00",
205+
// address, see above
206+
"7f0000018008",
207+
];
208+
let expected = HEXLOWER.decode(expected.concat().as_bytes()).unwrap();
209+
assert_eq!(base32, expected);
201210
}
202211
}

iroh-dns-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ z32 = "1.1.1"
6161
criterion = "0.5.1"
6262
hickory-resolver = "=0.25.0-alpha.4"
6363
iroh = { path = "../iroh" }
64-
iroh-test = { path = "../iroh-test" }
6564
pkarr = { version = "2.3.1", features = ["rand"] }
6665
rand = "0.8"
6766
rand_chacha = "0.3.1"
6867
testresult = "0.4.1"
68+
tracing-test = "0.2.5"
6969

7070
[[bench]]
7171
name = "write"

iroh-dns-server/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mod tests {
3434
};
3535
use pkarr::{PkarrClient, SignedPacket};
3636
use testresult::TestResult;
37+
use tracing_test::traced_test;
3738
use url::Url;
3839

3940
use crate::{
@@ -45,8 +46,8 @@ mod tests {
4546
};
4647

4748
#[tokio::test]
49+
#[traced_test]
4850
async fn pkarr_publish_dns_resolve() -> Result<()> {
49-
iroh_test::logging::setup_multithreaded();
5051
let (server, nameserver, http_url) = Server::spawn_for_tests().await?;
5152
let pkarr_relay_url = {
5253
let mut url = http_url.clone();
@@ -158,8 +159,8 @@ mod tests {
158159
}
159160

160161
#[tokio::test]
162+
#[traced_test]
161163
async fn integration_smoke() -> Result<()> {
162-
iroh_test::logging::setup_multithreaded();
163164
let (server, nameserver, http_url) = Server::spawn_for_tests().await?;
164165

165166
let pkarr_relay = {
@@ -190,8 +191,8 @@ mod tests {
190191
}
191192

192193
#[tokio::test]
194+
#[traced_test]
193195
async fn store_eviction() -> TestResult<()> {
194-
iroh_test::logging::setup_multithreaded();
195196
let options = ZoneStoreOptions {
196197
eviction: Duration::from_millis(100),
197198
eviction_interval: Duration::from_millis(100),
@@ -220,9 +221,8 @@ mod tests {
220221
}
221222

222223
#[tokio::test]
224+
#[traced_test]
223225
async fn integration_mainline() -> Result<()> {
224-
iroh_test::logging::setup_multithreaded();
225-
226226
// run a mainline testnet
227227
let testnet = pkarr::mainline::dht::Testnet::new(5);
228228
let bootstrap = testnet.bootstrap.clone();

iroh-net-report/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ url = { version = "2.4" }
3939

4040
[dev-dependencies]
4141
iroh-relay = { path = "../iroh-relay", features = ["test-utils", "server"] }
42-
iroh-test = { path = "../iroh-test" }
4342
pretty_assertions = "1.4"
4443
testresult = "0.4.0"
4544
tokio = { version = "1", default-features = false, features = ["test-util"] }
45+
tracing-test = "0.2.5"
4646

4747
[features]
4848
default = ["metrics"]

iroh-net-report/src/dns.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ pub(crate) mod tests {
187187
sync::{atomic::AtomicUsize, OnceLock},
188188
};
189189

190+
use tracing_test::traced_test;
191+
190192
use super::*;
191193

192194
static DNS_RESOLVER: OnceLock<TokioResolver> = OnceLock::new();
@@ -243,8 +245,8 @@ pub(crate) mod tests {
243245
}
244246

245247
#[tokio::test]
248+
#[traced_test]
246249
async fn stagger_basic() {
247-
let _logging = iroh_test::logging::setup();
248250
const CALL_RESULTS: &[Result<u8, u8>] = &[Err(2), Ok(3), Ok(5), Ok(7)];
249251
static DONE_CALL: AtomicUsize = AtomicUsize::new(0);
250252
let f = || {

iroh-net-report/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ mod tests {
10061006
use netwatch::IpFamily;
10071007
use tokio_util::sync::CancellationToken;
10081008
use tracing::info;
1009+
use tracing_test::traced_test;
10091010

10101011
use super::*;
10111012
use crate::{ping::Pinger, stun_utils::bind_local_stun_socket};
@@ -1143,8 +1144,8 @@ mod tests {
11431144
}
11441145

11451146
#[tokio::test]
1147+
#[traced_test]
11461148
async fn test_basic() -> Result<()> {
1147-
let _guard = iroh_test::logging::setup();
11481149
let (stun_addr, stun_stats, _cleanup_guard) =
11491150
stun_utils::serve("127.0.0.1".parse().unwrap()).await?;
11501151

@@ -1186,9 +1187,8 @@ mod tests {
11861187
}
11871188

11881189
#[tokio::test]
1190+
#[traced_test]
11891191
async fn test_udp_blocked() -> Result<()> {
1190-
let _guard = iroh_test::logging::setup();
1191-
11921192
// Create a "STUN server", which will never respond to anything. This is how UDP to
11931193
// the STUN server being blocked will look like from the client's perspective.
11941194
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;

iroh-net-report/src/ping.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ mod tests {
124124
use std::net::{Ipv4Addr, Ipv6Addr};
125125

126126
use tracing::error;
127+
use tracing_test::traced_test;
127128

128129
use super::*;
129130

130131
#[tokio::test]
131132
#[ignore] // Doesn't work in CI
133+
#[traced_test]
132134
async fn test_ping_google() -> Result<()> {
133-
let _guard = iroh_test::logging::setup();
134-
135135
// Public DNS addrs from google based on
136136
// https://developers.google.com/speed/public-dns/docs/using
137137

@@ -159,9 +159,8 @@ mod tests {
159159

160160
// See net_report::reportgen::tests::test_icmp_probe_eu_relay for permissions to ping.
161161
#[tokio::test]
162+
#[traced_test]
162163
async fn test_ping_localhost() {
163-
let _guard = iroh_test::logging::setup();
164-
165164
let pinger = Pinger::new();
166165

167166
match pinger.send(Ipv4Addr::LOCALHOST.into(), b"data").await {

0 commit comments

Comments
 (0)