From 8d87ea2ec153390bd13163d01d01758be56183f7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 12:58:48 +0100 Subject: [PATCH] cultmesh-rs tests: Drop sends an unsubscribe for each live id (drop-unsubscribes-untested) A live peer observes the unsubscribes a dropped client sends, one per live id and none for an id already unsubscribed. Co-Authored-By: Claude Opus 5.5 --- .../cultmesh-rs/tests/rudp_subscription.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/cultmesh-rs/tests/rudp_subscription.rs b/packages/cultmesh-rs/tests/rudp_subscription.rs index ec646e47..dde78d97 100644 --- a/packages/cultmesh-rs/tests/rudp_subscription.rs +++ b/packages/cultmesh-rs/tests/rudp_subscription.rs @@ -1232,3 +1232,27 @@ fn drop_does_not_wait_for_a_reconnect_to_a_silent_peer() { assert!(started.elapsed() < Duration::from_millis(300), "{:?}", started.elapsed()); assert!(pump.upgrade().is_none(), "the thread still stops"); } + +#[test] +fn drop_sends_an_unsubscribe_for_each_live_id() { + let peer = Peer::start(); + let client = CultMeshRudpSubscriptionClient::connect(options(&peer)).unwrap(); + client.subscribe("one", vector_selection()).unwrap(); + client.subscribe("two", vector_selection()).unwrap(); + client.subscribe("gone", vector_selection()).unwrap(); + client.unsubscribe("gone").unwrap(); + for _ in 0..3 { + peer.subscribe_id(); + } + assert!(matches!(peer.next(), CultNetMessage::DatabaseUnsubscribe { subscription_id, .. } if subscription_id == "gone")); + drop(client); + let mut unsubscribed: Vec = (0..2) + .map(|_| match peer.next() { + CultNetMessage::DatabaseUnsubscribe { subscription_id, .. } => subscription_id, + other => panic!("expected an unsubscribe, got {other:?}"), + }) + .collect(); + unsubscribed.sort(); + assert_eq!(unsubscribed, ["one", "two"]); + assert!(peer.received.recv_timeout(Duration::from_millis(300)).is_err(), "nothing else is sent"); +}