Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(profiles): add lease tests for profile leasing

Steven Enamakelb97175ffc569
diff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rs
index 562d4bf0ff..1f97068c42 100644
--- a/crates/openhuman-core/src/profiles/lease_tests.rs
+++ b/crates/openhuman-core/src/profiles/lease_tests.rs
@@ -203,15 +203,25 @@ async fn renewal_keeps_the_lease_and_a_lost_lease_fences_the_profile() {
assert_eq!(report.fenced, vec![alice.clone()]);
assert!(state.is_fenced(), "the profile is fenced");
assert!(!a.is_open(&alice), "and closed");
- assert!(turn.is_cancelled(), "its in-flight turns are stopped");
+ // The turn unwinds through the runner, which announces it afterwards.
+ tokio::time::timeout(Duration::from_secs(10), turn.cancelled())
+ .await
+ .expect("its in-flight turns are stopped");
// The cancelled event goes to the client that started the turn, so its
// stream resolves rather than staying "running".
- let mut cancelled_for = None;
- while let Ok(event) = events.try_recv() {
- if event.event == "chat_cancelled" && event.request_id == "req-1" {
- cancelled_for = Some(event.client_id);
+ let cancelled_for = tokio::time::timeout(Duration::from_secs(10), async {
+ loop {
+ match events.recv().await {
+ Ok(event) if event.event == "chat_cancelled" && event.thread_id == "t1" => {
+ return event.client_id;
+ }
+ Ok(_) | Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => continue,
+ Err(error) => panic!("event stream closed: {error}"),
+ }
}
- }
+ })
+ .await
+ .ok();
assert_eq!(cancelled_for.as_deref(), Some("test-client"));
}