node/test: Clean up

Adjusting visibility and conditional compilation for the modules in
`radicle_node::test` allows some dead code elimination.
This commit is contained in:
Lorenz Leutgeb
2026-07-21 12:32:42 +02:00
parent 8efbf06f78
commit 3658ece34f
4 changed files with 11 additions and 35 deletions
+9 -6
View File
@@ -1,7 +1,10 @@
pub mod gossip;
pub mod handle;
#[cfg(test)]
pub(crate) mod gossip;
#[cfg(test)]
pub(crate) mod handle;
#[cfg(any(test, feature = "test"))]
pub mod node;
pub mod peer;
pub mod simulator;
use radicle::test::*;
#[cfg(test)]
pub(crate) mod peer;
#[cfg(test)]
pub(crate) mod simulator;
-2
View File
@@ -7,8 +7,6 @@ use radicle::node::UserAgent;
use radicle::test::arbitrary;
use radicle::test::fixtures::r#gen;
use crate::test::arbitrary;
pub fn messages(count: usize, now: LocalTime, delta: LocalDuration) -> Vec<Message> {
let mut rng = fastrand::Rng::new();
let mut msgs = Vec::new();
+1 -10
View File
@@ -31,11 +31,10 @@ use radicle::node::routing::Store as _;
use radicle::node::{Address, Event, NodeId, Timestamp};
use radicle::node::{Alias, ConnectOptions, address};
use radicle::rad;
use radicle::storage::git::transport::remote;
use radicle::storage::WriteStorage;
use radicle::storage::refs;
use radicle::storage::refs::{RefsAt, SignedRefs};
use radicle::storage::{ReadRepository, RemoteRepository};
use radicle::storage::{RemoteId, WriteStorage};
use radicle::test::storage::MockStorage;
use radicle::test::{arbitrary, fixtures};
@@ -278,14 +277,6 @@ where
.unwrap()
}
pub fn git_url(&self, repo: RepoId, namespace: Option<RemoteId>) -> remote::Url {
remote::Url {
node: *self.nid(),
repo,
namespace,
}
}
pub fn receive(&mut self, peer: NodeId, msg: Message) -> &mut Self {
self.service.received_message(peer, msg);
self
+1 -17
View File
@@ -22,15 +22,12 @@ use radicle::node::NodeId;
use radicle::node::events::Event;
use radicle::storage::Namespaces;
use radicle::storage::{ReadRepository, WriteStorage};
use crate::test::arbitrary;
use radicle::test::arbitrary;
use super::peer::Peer;
/// Minimum latency between peers.
pub const MIN_LATENCY: LocalDuration = LocalDuration::from_millis(1);
/// Maximum number of events buffered per peer.
pub const MAX_EVENTS: usize = 2048;
/// Simulated service input.
#[derive(Debug, Clone)]
@@ -239,11 +236,6 @@ where
.all(|(_, s)| matches!(s.input, Input::Wake))
}
/// Get a node's emitted events.
pub fn events(&mut self, node: &NodeId) -> impl Iterator<Item = Event> + '_ {
self.events.entry(*node).or_default().drain(..)
}
/// Get all messages received by nodes during the simulation.
pub fn messages(&mut self) -> &[(NodeId, NodeId, Message)] {
&self.messages
@@ -277,14 +269,6 @@ where
}
}
/// Process one scheduled input from the inbox, using the provided peers.
/// This function should be called until it returns `false`, or some desired state is reached.
/// Returns `true` if there are more messages to process.
pub fn step<'a>(&mut self, peers: impl IntoIterator<Item = &'a mut Peer<S>>) -> bool {
let mut nodes: BTreeMap<_, _> = peers.into_iter().map(|p| (*p.nid(), p)).collect();
self.step_(&mut nodes)
}
fn step_(&mut self, nodes: &mut BTreeMap<NodeId, &mut Peer<S>>) -> bool {
if !self.opts.latency.is_empty() {
// Configure latencies.