From c46bc0cc82472ef615d8c45de0e54da78925da42 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 16 Mar 2023 15:15:30 +0100 Subject: [PATCH] node: Start periodic tasks This change ensures that we start the periodic tasks "loop" by scheduling the first wakeup during initialization. --- radicle-node/src/service.rs | 2 ++ radicle-node/src/test/peer.rs | 5 +++-- radicle-node/src/tests.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index f8c38a74..591bc653 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -385,6 +385,8 @@ where .repo_policies()? .filter_map(|t| (t.policy == tracking::Policy::Track).then_some(t.id)), ); + // Start periodic tasks. + self.reactor.wakeup(IDLE_INTERVAL); Ok(()) } diff --git a/radicle-node/src/test/peer.rs b/radicle-node/src/test/peer.rs index 6adf9208..a69c9915 100644 --- a/radicle-node/src/test/peer.rs +++ b/radicle-node/src/test/peer.rs @@ -22,7 +22,6 @@ use crate::storage::git::transport::remote; use crate::storage::Inventory; use crate::storage::{RemoteId, WriteStorage}; use crate::test::arbitrary; -use crate::test::assert_matches; use crate::test::simulator; use crate::test::storage::MockStorage; use crate::Link; @@ -281,7 +280,9 @@ where self.service .command(Command::Connect(remote_id, remote_addr.clone())); - assert_matches!(self.outbox().next(), Some(Io::Connect { .. })); + self.outbox() + .find(|o| matches!(o, Io::Connect { .. })) + .unwrap(); self.service.attempted(remote_id, &remote_addr); self.service.connected(remote_id, Link::Outbound); diff --git a/radicle-node/src/tests.rs b/radicle-node/src/tests.rs index b00da545..1da9b6c8 100644 --- a/radicle-node/src/tests.rs +++ b/radicle-node/src/tests.rs @@ -218,7 +218,7 @@ fn test_persistent_peer_connect() { let mut outbox = alice.outbox(); assert_matches!(outbox.next(), Some(Io::Connect(a, _)) if a == bob.id()); assert_matches!(outbox.next(), Some(Io::Connect(a, _)) if a == eve.id()); - assert_matches!(outbox.next(), None); + assert_matches!(outbox.find(|o| matches!(o, Io::Connect { .. })), None); } #[test]