Skip to content

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

fix(tests): update test files to use new wallet test support

Steven Enamakel7bdd6d3ee6d2
diff --git a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
index 904d54bcd9..451998805d 100644
--- a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
@@ -313,7 +313,7 @@ async fn regenerate_reruns_producer_and_reuses_id() {
/// Points the default files folder (`OPENHUMAN_PROJECTS_DIR/Files`) at a temp
/// dir for one test, holding the shared env lock, and restores it on drop.
struct DefaultFilesDir {
- _lock: std::sync::MutexGuard<'static, ()>,
+ _lock: tokio::sync::MutexGuard<'static, ()>,
previous: Option<std::ffi::OsString>,
files_dir: std::path::PathBuf,
}
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
index c4955208e3..9696a0d863 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use std::sync::MutexGuard;
+use tokio::sync::MutexGuard;
/// Serializes every test that touches the global [`QUEUE`]. We reuse the
/// crate-wide `TEST_ENV_LOCK` because `clear_all` is also reachable from the
diff --git a/crates/openhuman-core/src/agent/todos/ops.rs b/crates/openhuman-core/src/agent/todos/ops.rs
index 5e16f940b4..bb3457cb1b 100644
--- a/crates/openhuman-core/src/agent/todos/ops.rs
+++ b/crates/openhuman-core/src/agent/todos/ops.rs
@@ -64,10 +64,15 @@ pub async fn list(workspace_dir: &Path, scope: &TodoScope) -> Result<TodosSnapsh
}
#[cfg(test)]
-pub(crate) fn scratch_test_lock() -> std::sync::MutexGuard<'static, ()> {
- use std::sync::{Mutex, OnceLock};
- static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
- LOCK.get_or_init(|| Mutex::new(()))
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
+pub(crate) fn scratch_test_lock() -> tokio::sync::MutexGuard<'static, ()> {
+ SCRATCH_TEST_LOCK.blocking_lock()
}
+
+/// Async form for `#[tokio::test]` bodies, so the guard may be held across `.await`.
+#[cfg(test)]
+pub(crate) async fn scratch_test_lock_async() -> tokio::sync::MutexGuard<'static, ()> {
+ SCRATCH_TEST_LOCK.lock().await
+}
+
+#[cfg(test)]
+static SCRATCH_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
diff --git a/crates/openhuman-core/src/agent/tools/todo_tests.rs b/crates/openhuman-core/src/agent/tools/todo_tests.rs
index 5237c4e4f0..dd2d9c7a16 100644
--- a/crates/openhuman-core/src/agent/tools/todo_tests.rs
+++ b/crates/openhuman-core/src/agent/tools/todo_tests.rs
@@ -10,7 +10,7 @@ fn scratch_lock() -> tokio::sync::MutexGuard<'static, ()> {
}
async fn scratch_lock_async() -> tokio::sync::MutexGuard<'static, ()> {
- crate::agent::todos::ops::scratch_test_lock()
+ crate::agent::todos::ops::scratch_test_lock_async().await
}
/// A fresh on-disk workspace root for one test's `FileStore`-backed todo
diff --git a/crates/openhuman-core/src/config/schema/load_tests.rs b/crates/openhuman-core/src/config/schema/load_tests.rs
index 2861edc584..d7f5bbe5be 100644
--- a/crates/openhuman-core/src/config/schema/load_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load_tests.rs
@@ -80,7 +80,7 @@ async fn write_file(path: &std::path::Path, contents: &str) {
const CORRUPTED_TOML: &str = "{{{ bad table header\n";
-fn env_lock() -> std::sync::MutexGuard<'static, ()> {
+fn env_lock() -> tokio::sync::MutexGuard<'static, ()> {
ENV_LOCK.blocking_lock()
}
diff --git a/crates/openhuman-core/src/integrations/composio/ops_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_tests.rs
index ab303374a4..c028726510 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_tests.rs
@@ -17,7 +17,7 @@ fn test_config(tmp: &tempfile::TempDir) -> Config {
/// Per-module alias so call sites don't need to spell out the path.
/// The actual lock lives in `connected_integrations` so it is shared
/// with `tools_tests` and any other test module that touches the cache.
-fn cache_guard() -> std::sync::MutexGuard<'static, ()> {
+fn cache_guard() -> tokio::sync::MutexGuard<'static, ()> {
crate::integrations::composio::connected_integrations::composio_cache_test_lock()
}
diff --git a/crates/openhuman-core/src/threads/ops/live_state_tests.rs b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
index 436a79a02d..7abd0c26f7 100644
--- a/crates/openhuman-core/src/threads/ops/live_state_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
@@ -18,7 +18,7 @@ fn thread_live_state_request_parses_thread_id() {
}
struct WorkspaceGuard {
- _lock: std::sync::MutexGuard<'static, ()>,
+ _lock: tokio::sync::MutexGuard<'static, ()>,
_tmp: tempfile::TempDir,
}
diff --git a/crates/openhuman-core/src/web3/wallet/test_support.rs b/crates/openhuman-core/src/web3/wallet/test_support.rs
index 8728e25c28..ec23dd88c0 100644
--- a/crates/openhuman-core/src/web3/wallet/test_support.rs
+++ b/crates/openhuman-core/src/web3/wallet/test_support.rs
@@ -76,12 +76,14 @@ pub(crate) static RPC_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(())
/// previous values are restored on drop.
pub(crate) struct UnreachableRpcGuard {
previous: Vec<(&'static str, Option<std::ffi::OsString>)>,
- _env_lock: std::sync::MutexGuard<'static, ()>,
+ _env_lock: tokio::sync::MutexGuard<'static, ()>,
}
impl UnreachableRpcGuard {
pub(crate) fn set() -> Self {
- let env_lock = RPC_ENV_LOCK.blocking_lock();
+ let env_lock = RPC_ENV_LOCK
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner());
// Bind then drop to learn a port that is free, hence refusing.
let port = std::net::TcpListener::bind("127.0.0.1:0")
.and_then(|listener| listener.local_addr())