Skip to content

refactor!: remove iroh-test crate #3162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
SCCACHE_CACHE_SIZE: "10G"
CRATES_LIST: "iroh,iroh-bench,iroh-test,iroh-dns-server,iroh-relay,iroh-net-report"
CRATES_LIST: "iroh,iroh-bench,iroh-dns-server,iroh-relay,iroh-net-report"
IROH_FORCE_STAGING_RELAYS: "1"

jobs:
Expand Down
52 changes: 25 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ members = [
"iroh-base",
"iroh-dns-server",
"iroh",
"iroh-test",
"iroh/bench",
"iroh-relay",
"iroh-net-report",
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ This repository contains a workspace of crates:
- `iroh`: The core library for hole-punching & communicating with relays.
- `iroh-relay`: The relay server implementation. This is the code we run in production (and you can, too!).
- `iroh-base`: Common types like `Hash`, key types or `RelayUrl`.
- `iroh-test`: Test utilities.
- `iroh-dns-server`: DNS server implementation powering the `n0_discovery` for NodeIds, running at dns.iroh.link.
- `iroh-net-report`: Analyzes your host's networking ability & NAT.

Expand Down
1 change: 0 additions & 1 deletion iroh-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ thiserror = { version = "2", optional = true }
getrandom = { version = "0.2", default-features = false, optional = true }

[dev-dependencies]
iroh-test = "0.28.0"
postcard = { version = "1", features = ["use-std"] }
proptest = "1.0.0"
rand = "0.8"
Expand Down
10 changes: 5 additions & 5 deletions iroh-base/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn decode_base32_hex(s: &str) -> Result<[u8; 32], KeyParsingError> {

#[cfg(test)]
mod tests {
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
use data_encoding::HEXLOWER;

use super::*;

Expand All @@ -360,10 +360,10 @@ mod tests {
PublicKey::from_str("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
.unwrap();
let bytes = postcard::to_stdvec(&public_key).unwrap();
let expected =
parse_hexdump("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
.unwrap();
assert_eq_hex!(bytes, expected);
let expected = HEXLOWER
.decode(b"ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6")
.unwrap();
assert_eq!(bytes, expected);
}

#[test]
Expand Down
31 changes: 20 additions & 11 deletions iroh-base/src/ticket/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'de> Deserialize<'de> for NodeTicket {
mod tests {
use std::net::{Ipv4Addr, SocketAddr};

use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
use data_encoding::HEXLOWER;

use super::*;
use crate::key::{PublicKey, SecretKey};
Expand Down Expand Up @@ -188,15 +188,24 @@ mod tests {
.as_bytes(),
)
.unwrap();
let expected = parse_hexdump("
00 # variant
ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6 # node id, 32 bytes, see above
01 # relay url present
10 687474703a2f2f646572702e6d652e2f # relay url, 16 bytes, see above
01 # one direct address
00 # ipv4
7f000001 8008 # address, see above
").unwrap();
assert_eq_hex!(base32, expected);
let expected = [
// variant
"00",
// node id, 32 bytes, see above
"ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6",
// relay url present
"01",
// relay url, 16 bytes, see above
"10",
"687474703a2f2f646572702e6d652e2f",
// one direct address
"01",
// ipv4
"00",
// address, see above
"7f0000018008",
];
let expected = HEXLOWER.decode(expected.concat().as_bytes()).unwrap();
assert_eq!(base32, expected);
}
}
2 changes: 1 addition & 1 deletion iroh-dns-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ z32 = "1.1.1"
criterion = "0.5.1"
hickory-resolver = "=0.25.0-alpha.4"
iroh = { path = "../iroh" }
iroh-test = { path = "../iroh-test" }
pkarr = { version = "2.3.1", features = ["rand"] }
rand = "0.8"
rand_chacha = "0.3.1"
testresult = "0.4.1"
tracing-test = "0.2.5"

[[bench]]
name = "write"
Expand Down
10 changes: 5 additions & 5 deletions iroh-dns-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mod tests {
};
use pkarr::{PkarrClient, SignedPacket};
use testresult::TestResult;
use tracing_test::traced_test;
use url::Url;

use crate::{
Expand All @@ -45,8 +46,8 @@ mod tests {
};

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

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

let pkarr_relay = {
Expand Down Expand Up @@ -190,8 +191,8 @@ mod tests {
}

#[tokio::test]
#[traced_test]
async fn store_eviction() -> TestResult<()> {
iroh_test::logging::setup_multithreaded();
let options = ZoneStoreOptions {
eviction: Duration::from_millis(100),
eviction_interval: Duration::from_millis(100),
Expand Down Expand Up @@ -220,9 +221,8 @@ mod tests {
}

#[tokio::test]
#[traced_test]
async fn integration_mainline() -> Result<()> {
iroh_test::logging::setup_multithreaded();

// run a mainline testnet
let testnet = pkarr::mainline::dht::Testnet::new(5);
let bootstrap = testnet.bootstrap.clone();
Expand Down
2 changes: 1 addition & 1 deletion iroh-net-report/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ url = { version = "2.4" }

[dev-dependencies]
iroh-relay = { path = "../iroh-relay", features = ["test-utils", "server"] }
iroh-test = { path = "../iroh-test" }
pretty_assertions = "1.4"
testresult = "0.4.0"
tokio = { version = "1", default-features = false, features = ["test-util"] }
tracing-test = "0.2.5"

[features]
default = ["metrics"]
Expand Down
4 changes: 3 additions & 1 deletion iroh-net-report/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ pub(crate) mod tests {
sync::{atomic::AtomicUsize, OnceLock},
};

use tracing_test::traced_test;

use super::*;

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

#[tokio::test]
#[traced_test]
async fn stagger_basic() {
let _logging = iroh_test::logging::setup();
const CALL_RESULTS: &[Result<u8, u8>] = &[Err(2), Ok(3), Ok(5), Ok(7)];
static DONE_CALL: AtomicUsize = AtomicUsize::new(0);
let f = || {
Expand Down
6 changes: 3 additions & 3 deletions iroh-net-report/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ mod tests {
use netwatch::IpFamily;
use tokio_util::sync::CancellationToken;
use tracing::info;
use tracing_test::traced_test;

use super::*;
use crate::{ping::Pinger, stun_utils::bind_local_stun_socket};
Expand Down Expand Up @@ -1143,8 +1144,8 @@ mod tests {
}

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

Expand Down Expand Up @@ -1186,9 +1187,8 @@ mod tests {
}

#[tokio::test]
#[traced_test]
async fn test_udp_blocked() -> Result<()> {
let _guard = iroh_test::logging::setup();

// Create a "STUN server", which will never respond to anything. This is how UDP to
// the STUN server being blocked will look like from the client's perspective.
let blackhole = tokio::net::UdpSocket::bind("127.0.0.1:0").await?;
Expand Down
7 changes: 3 additions & 4 deletions iroh-net-report/src/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ mod tests {
use std::net::{Ipv4Addr, Ipv6Addr};

use tracing::error;
use tracing_test::traced_test;

use super::*;

#[tokio::test]
#[ignore] // Doesn't work in CI
#[traced_test]
async fn test_ping_google() -> Result<()> {
let _guard = iroh_test::logging::setup();

// Public DNS addrs from google based on
// https://developers.google.com/speed/public-dns/docs/using

Expand Down Expand Up @@ -159,9 +159,8 @@ mod tests {

// See net_report::reportgen::tests::test_icmp_probe_eu_relay for permissions to ping.
#[tokio::test]
#[traced_test]
async fn test_ping_localhost() {
let _guard = iroh_test::logging::setup();

let pinger = Pinger::new();

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