diff --git a/crates/rns-transport/src/actor/mod.rs b/crates/rns-transport/src/actor/mod.rs index 76e9838..2348a43 100644 --- a/crates/rns-transport/src/actor/mod.rs +++ b/crates/rns-transport/src/actor/mod.rs @@ -554,7 +554,7 @@ impl TransportActor { if let Some(ref target) = aspect_filter { registration.aspect_filter.as_ref() != Some(target) } else { - true + false } }); } @@ -1865,6 +1865,29 @@ mod tests { assert!(!actor.local_destinations.contains(&hash)); } + #[test] + fn deregister_announce_handler_without_filter_removes_all() { + let (mut actor, _tx) = TransportActor::new(); + let (first_tx, _first_rx) = mpsc::channel(1); + let (second_tx, _second_rx) = mpsc::channel(1); + actor.handle_message(TransportMessage::RegisterAnnounceHandler { + aspect_filter: Some("first.aspect".into()), + receive_path_responses: false, + callback_tx: first_tx, + }); + actor.handle_message(TransportMessage::RegisterAnnounceHandler { + aspect_filter: None, + receive_path_responses: true, + callback_tx: second_tx, + }); + assert_eq!(actor.announce_handlers.len(), 2); + + actor.handle_message(TransportMessage::DeregisterAnnounceHandler { + aspect_filter: None, + }); + assert!(actor.announce_handlers.is_empty()); + } + #[tokio::test] async fn test_actor_shutdown() { let (actor, tx) = TransportActor::new();