node: Various small fixes
This commit is contained in:
parent
4307bdaae4
commit
9576a6496b
|
|
@ -654,6 +654,8 @@ where
|
||||||
self.last_sync = now;
|
self.last_sync = now;
|
||||||
}
|
}
|
||||||
if now - self.last_announce >= ANNOUNCE_INTERVAL {
|
if now - self.last_announce >= ANNOUNCE_INTERVAL {
|
||||||
|
trace!(target: "service", "Running 'announce' task...");
|
||||||
|
|
||||||
if let Err(err) = self
|
if let Err(err) = self
|
||||||
.storage
|
.storage
|
||||||
.inventory()
|
.inventory()
|
||||||
|
|
|
||||||
|
|
@ -555,8 +555,8 @@ pub fn converge<'a, G: Signer + cyphernet::Ecdh + 'static>(
|
||||||
log::debug!(target: "test", "Node {} has converged", node.id);
|
log::debug!(target: "test", "Node {} has converged", node.id);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
log::debug!(target: "test", "Node {} has {:?}", node.id, routes);
|
let diff = all_routes.symmetric_difference(&routes).collect::<Vec<_>>();
|
||||||
log::debug!(target: "test", "All routes {:?}", all_routes);
|
log::debug!(target: "test", "Node has missing routes: {diff:?}");
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ pub struct Simulation<S, G> {
|
||||||
/// Events emitted during simulation.
|
/// Events emitted during simulation.
|
||||||
events: BTreeMap<NodeId, VecDeque<Event>>,
|
events: BTreeMap<NodeId, VecDeque<Event>>,
|
||||||
/// Messages received during simulation.
|
/// Messages received during simulation.
|
||||||
messages: Vec<Message>,
|
messages: Vec<(NodeId, NodeId, Message)>,
|
||||||
/// Priority events that should happen immediately.
|
/// Priority events that should happen immediately.
|
||||||
priority: VecDeque<Scheduled>,
|
priority: VecDeque<Scheduled>,
|
||||||
/// Simulated latencies between nodes.
|
/// Simulated latencies between nodes.
|
||||||
|
|
@ -250,7 +250,7 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all messages received by nodes during the simulation.
|
/// Get all messages received by nodes during the simulation.
|
||||||
pub fn messages(&mut self) -> &[Message] {
|
pub fn messages(&mut self) -> &[(NodeId, NodeId, Message)] {
|
||||||
&self.messages
|
&self.messages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -400,11 +400,12 @@ impl<S: WriteStorage + 'static, G: Signer> Simulation<S, G> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Input::Wake => p.wake(),
|
Input::Wake => p.wake(),
|
||||||
Input::Received(id, msgs) => {
|
Input::Received(from, msgs) => {
|
||||||
for msg in msgs.clone() {
|
for msg in msgs.clone() {
|
||||||
p.received_message(id, msg);
|
p.received_message(from, msg);
|
||||||
}
|
}
|
||||||
self.messages.extend(msgs);
|
self.messages
|
||||||
|
.extend(msgs.into_iter().map(|m| (from, p.node_id(), m)));
|
||||||
}
|
}
|
||||||
Input::Fetched(rid, nid, result) => {
|
Input::Fetched(rid, nid, result) => {
|
||||||
let result = Rc::try_unwrap(result).unwrap();
|
let result = Rc::try_unwrap(result).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,7 @@ fn test_announcement_rebroadcast_duplicates() {
|
||||||
let eve = Peer::new("eve", [9, 9, 9, 9]);
|
let eve = Peer::new("eve", [9, 9, 9, 9]);
|
||||||
let rids = arbitrary::set::<RepoId>(3..=3);
|
let rids = arbitrary::set::<RepoId>(3..=3);
|
||||||
|
|
||||||
|
carol.init();
|
||||||
alice.connect_to(&bob);
|
alice.connect_to(&bob);
|
||||||
alice.receive(bob.id, carol.node_announcement());
|
alice.receive(bob.id, carol.node_announcement());
|
||||||
|
|
||||||
|
|
@ -936,6 +937,8 @@ fn test_inventory_relay() {
|
||||||
let now = LocalTime::now().as_millis();
|
let now = LocalTime::now().as_millis();
|
||||||
|
|
||||||
// Inventory from Bob relayed to Eve.
|
// Inventory from Bob relayed to Eve.
|
||||||
|
alice.init();
|
||||||
|
alice.wake(); // Run all periodic tasks now so they don't trigger later.
|
||||||
alice.connect_to(&bob);
|
alice.connect_to(&bob);
|
||||||
alice.connect_from(&eve);
|
alice.connect_from(&eve);
|
||||||
alice.receive(
|
alice.receive(
|
||||||
|
|
@ -1399,7 +1402,7 @@ fn test_queued_fetch_from_ann_same_rid() {
|
||||||
// The first fetch is initiated.
|
// The first fetch is initiated.
|
||||||
assert_matches!(alice.fetches().next(), Some((rid_, nid_, _)) if rid_ == rid && nid_ == bob.id);
|
assert_matches!(alice.fetches().next(), Some((rid_, nid_, _)) if rid_ == rid && nid_ == bob.id);
|
||||||
// We shouldn't send out the 2nd, 3rd fetch while we're doing the 1st fetch.
|
// We shouldn't send out the 2nd, 3rd fetch while we're doing the 1st fetch.
|
||||||
assert_matches!(alice.outbox().next(), None);
|
assert_matches!(alice.fetches().next(), None);
|
||||||
|
|
||||||
// Have enough time pass that Alice sends a "ping" to Bob.
|
// Have enough time pass that Alice sends a "ping" to Bob.
|
||||||
alice.elapse(KEEP_ALIVE_DELTA);
|
alice.elapse(KEEP_ALIVE_DELTA);
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ fn test_inventory_sync_bridge() {
|
||||||
eve.project("eve", "");
|
eve.project("eve", "");
|
||||||
|
|
||||||
let mut alice = alice.spawn();
|
let mut alice = alice.spawn();
|
||||||
let mut bob = bob.spawn();
|
let mut eve = eve.spawn();
|
||||||
let eve = eve.spawn();
|
let bob = bob.spawn();
|
||||||
|
|
||||||
alice.connect(&bob);
|
alice.connect(&bob);
|
||||||
bob.connect(&eve);
|
eve.connect(&bob);
|
||||||
|
|
||||||
let routes = converge([&alice, &bob, &eve]);
|
let routes = converge([&alice, &bob, &eve]);
|
||||||
assert_eq!(routes.len(), 3);
|
assert_eq!(routes.len(), 3);
|
||||||
|
|
|
||||||
|
|
@ -837,7 +837,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Io::Wakeup(d) => {
|
Io::Wakeup(d) => {
|
||||||
self.actions.push_back(reactor::Action::SetTimer(d.into()));
|
self.actions.push_back(reactor::Action::SetTimer(
|
||||||
|
// TODO: Remove this when `io-reactor` can handle `0` duration timeouts.
|
||||||
|
d.max(localtime::LocalDuration::from_millis(1)).into(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Io::Fetch {
|
Io::Fetch {
|
||||||
rid,
|
rid,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue