Skip to content

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

fix(test): update test imports for moved types

Steven Enamakel2142516cd92f
diff --git a/crates/openhuman-core/src/backend/client_channel_tests.rs b/crates/openhuman-core/src/backend/client_channel_tests.rs
index a12ce0d5db..6b3bdec06e 100644
--- a/crates/openhuman-core/src/backend/client_channel_tests.rs
+++ b/crates/openhuman-core/src/backend/client_channel_tests.rs
@@ -59,7 +59,7 @@ async fn channel_routes_build_expected_requests_and_validate_inputs() {
.await
.unwrap();
- let requests = seen.lock().unwrap();
+ let requests = seen.lock().unwrap().clone();
assert_eq!(
requests[0],
(
diff --git a/crates/openhuman-core/src/platform/socket/manager_tests.rs b/crates/openhuman-core/src/platform/socket/manager_tests.rs
index 564eceb37a..cb632d4a3b 100644
--- a/crates/openhuman-core/src/platform/socket/manager_tests.rs
+++ b/crates/openhuman-core/src/platform/socket/manager_tests.rs
@@ -246,33 +246,22 @@ async fn emit_cannot_send_past_a_concurrent_teardown_drain() {
*mgr.shared.status.write() = ConnectionStatus::Connected;
// Teardown begins: take the gate before clearing it, mirroring `ws_loop`'s
- // "clear the flag and drain under the same lock" critical section.
- let mut teardown_guard = gate.lock();
-
- // A concurrent emit starts while teardown holds the gate.
- let emit_mgr = Arc::clone(&mgr);
- let mut emit_task =
- tokio::spawn(async move { emit_mgr.emit("test.event", json!({ "k": "v" })).await });
-
- // While the gate is held, `emit` must not be able to complete: it is blocked
- // at its readiness check on the same lock teardown holds. A bare atomic flag
- // would let it read `true` and send here, past the drain below.
- assert!(
- tokio::time::timeout(Duration::from_millis(200), &mut emit_task)
- .await
- .is_err(),
- "emit must block on the readiness gate while teardown holds it"
- );
-
- // Teardown's clear + drain, under the held lock. `drain_pending_emits` lives
- // in the sibling `ws_loop` module; the loop replicates its try_recv sweep.
- *teardown_guard = false;
- let mut drained = 0usize;
- while rx.try_recv().is_ok() {
- drained += 1;
- }
+ // "clear the flag and drain under the same lock" critical section. The gate is
+ // a synchronous leaf lock (never held over an `.await` in production), so
+ // teardown runs on its own OS thread rather than as a guard held across the
+ // awaits below; the test task steps it through `release_tx`.
+ let (locked_tx, locked_rx) = tokio::sync::oneshot::channel::<()>();
+ let (release_tx, release_rx) = std::sync::mpsc::channel::<()>();
+ let teardown_gate = Arc::clone(&gate);
+ let teardown = std::thread::spawn(move || {
+ let mut teardown_guard = teardown_gate.lock();
+ locked_tx.send(()).expect("test task is waiting for the lock");
+ release_rx
+ .recv()
+ .expect("test task releases teardown after the pending-while-locked check");
+ release_tx.send(()).expect("teardown thread is waiting");
+ let (drained, mut rx) = teardown.join().expect("teardown thread must not panic");
assert_eq!(drained, 0, "nothing was queued before teardown began");
- drop(teardown_guard);
// With the gate released and cleared, the previously-blocked emit resumes,
// sees `ready == false`, and rejects — enqueuing nothing onto the channel