bg bugfix

This commit is contained in:
yves committed 2026-11-20 23:48:30 +01:00
1 parent 7eace57528
commit c30fddb1ef
14 files changed
+3809 -12

No files matched your search

+45
View File
@@ -771,3 +771,48 @@ async fn invitations_straight_into_hidden_spaces() {
assert_eq!(texts(&bob.sync(Duration::ZERO).await.unwrap()), vec!["still secret"]);
let _ = std::fs::remove_dir_all(&dir);
}
/// The background task must notice state changes made through the handle (here, a
/// first contact while it was idling), not only after its 30 s wait.
#[tokio::test(flavor = "multi_thread")]
async fn background_task_wakes_up_on_new_contacts() {
let servers = vec![spawn_server().await];
let dir = tmpdir();
let alice = client(&dir, "alice", &servers)
.await
.start(meow_client::BackgroundOptions::default());
let bob = client(&dir, "bob", &servers)
.await
.start(meow_client::BackgroundOptions::default());
let alice_rx = alice.subscribe();
let bob_rx = bob.subscribe();
tokio::time::sleep(Duration::from_millis(300)).await; // both idle, nothing to poll
let url = alice
.lock()
.await
.publish_invitation("bob", &[], "", "", 3600, None)
.await
.unwrap();
bob.lock()
.await
.accept_published_invitation(&url, "", None, &[], None)
.await
.unwrap();
async fn activated(mut rx: tokio::sync::broadcast::Receiver<Event>, who: &str) {
tokio::time::timeout(Duration::from_secs(10), async {
loop {
if let Event::ContactActivated { .. } = rx.recv().await.unwrap() {
return;
}
}
})
.await
.unwrap_or_else(|_| panic!("{who} not activated in time"))
}
let (a, b) = (activated(alice_rx, "alice"), activated(bob_rx, "bob"));
tokio::join!(a, b);
alice.stop().await;
bob.stop().await;
let _ = std::fs::remove_dir_all(&dir);
}