Skip to content

Commit

Permalink
test: use persistent node ids to make log parsing easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed May 21, 2024
1 parent 4268bc2 commit dfa9bd8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ fn decode_peer_data(peer_data: &PeerData) -> anyhow::Result<AddrInfo> {
mod test {
use std::time::Duration;

use iroh_net::key::SecretKey;
use iroh_net::relay::{RelayMap, RelayMode};
use tokio::spawn;
use tokio::time::timeout;
Expand All @@ -661,8 +662,12 @@ mod test {

use super::*;

async fn create_endpoint(relay_map: RelayMap) -> anyhow::Result<Endpoint> {
async fn create_endpoint(
rng: &mut rand_chacha::ChaCha12Rng,
relay_map: RelayMap,
) -> anyhow::Result<Endpoint> {
Endpoint::builder()
.secret_key(SecretKey::generate_with_rng(rng))
.alpns(vec![GOSSIP_ALPN.to_vec()])
.relay_mode(RelayMode::Custom(relay_map))
.insecure_skip_relay_cert_verify(true)
Expand Down Expand Up @@ -690,13 +695,14 @@ mod test {

#[tokio::test]
async fn gossip_net_smoke() {
let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(1);
let _guard = iroh_test::logging::setup();
let (relay_map, relay_url, _guard) =
iroh_net::test_utils::run_relay_server().await.unwrap();

let ep1 = create_endpoint(relay_map.clone()).await.unwrap();
let ep2 = create_endpoint(relay_map.clone()).await.unwrap();
let ep3 = create_endpoint(relay_map.clone()).await.unwrap();
let ep1 = create_endpoint(&mut rng, relay_map.clone()).await.unwrap();
let ep2 = create_endpoint(&mut rng, relay_map.clone()).await.unwrap();
let ep3 = create_endpoint(&mut rng, relay_map.clone()).await.unwrap();
let addr1 = AddrInfo {
relay_url: Some(relay_url.clone()),
direct_addresses: Default::default(),
Expand Down

0 comments on commit dfa9bd8

Please sign in to comment.