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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-28 12:58:48 +01:00
commit 8d87ea2ec1

View file

@ -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<String> = (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");
}