Skip to content

Commit ac16d05

Browse files
committed
review: follow-up for comments
1 parent b265eb9 commit ac16d05

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

node/testing/src/node/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ pub enum NodeTestingConfig {
1111

1212
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
1313
pub enum TestPeerId {
14+
/// NOTE This option results a deterministic private key derived from the
15+
/// node index in the cluster. Be aware that when interacting with OCaml
16+
/// nodes or other nodes outside the cluster might be interfer by previous
17+
/// runs (e.g. peer_id might be blacklisted).
1418
#[default]
1519
Derived,
1620
Random,

node/testing/src/scenarios/driver.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use libp2p::Multiaddr;
44
use node::{
55
event_source::Event,
66
p2p::{
7-
connection::outgoing::P2pConnectionOutgoingInitOpts, P2pConnectionEvent, P2pEvent,
8-
P2pListenEvent, P2pListenerId, PeerId,
7+
connection::outgoing::P2pConnectionOutgoingInitOpts,
8+
webrtc::{Host, HttpSignalingInfo, SignalingMethod},
9+
P2pConnectionEvent, P2pEvent, P2pListenEvent, P2pListenerId, PeerId,
910
},
1011
State,
1112
};
@@ -19,6 +20,22 @@ pub fn match_addr_with_port_and_peer_id(
1920
peer_id: PeerId,
2021
) -> impl Fn(&P2pConnectionOutgoingInitOpts) -> bool {
2122
move |conn_opt| match conn_opt {
23+
P2pConnectionOutgoingInitOpts::WebRTC {
24+
peer_id: pid,
25+
signaling:
26+
SignalingMethod::Http(HttpSignalingInfo {
27+
host: Host::Ipv4(_ip4),
28+
port: p,
29+
}),
30+
}
31+
| P2pConnectionOutgoingInitOpts::WebRTC {
32+
peer_id: pid,
33+
signaling:
34+
SignalingMethod::Https(HttpSignalingInfo {
35+
host: Host::Ipv4(_ip4),
36+
port: p,
37+
}),
38+
} => &peer_id == pid && port == *p,
2239
P2pConnectionOutgoingInitOpts::LibP2P(libp2p_opts) => {
2340
&libp2p_opts.peer_id == &peer_id && libp2p_opts.port == port
2441
}
@@ -352,7 +369,11 @@ where
352369
/// Runs cluster until there is a `quiet_dur` period of no events, returning
353370
/// `Ok(true)` in this case. If there is no such period for `timeout` period of
354371
/// time, then returns `Ok(false)`
355-
pub async fn run_until_no_events<'cluster>(driver: &mut Driver<'cluster>, quiet_dur: Duration, timeout: Duration) -> anyhow::Result<bool> {
372+
pub async fn run_until_no_events<'cluster>(
373+
driver: &mut Driver<'cluster>,
374+
quiet_dur: Duration,
375+
timeout: Duration,
376+
) -> anyhow::Result<bool> {
356377
let timeout = Instant::now() + timeout;
357378
while driver.run_until(quiet_dur, |_, _, _| true).await? {
358379
if Instant::now() >= timeout {

0 commit comments

Comments
 (0)