Skip to content

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

chore(tests): gate test helpers behind cfg(test)

Steven Enamakelfdb3e7f0412b
diff --git a/crates/openhuman-core/src/agent/orchestration/completion_notice.rs b/crates/openhuman-core/src/agent/orchestration/completion_notice.rs
index f72d76ff65..b68eccd784 100644
--- a/crates/openhuman-core/src/agent/orchestration/completion_notice.rs
+++ b/crates/openhuman-core/src/agent/orchestration/completion_notice.rs
@@ -147,7 +147,9 @@ fn display_task_id(record: &CompletionRecord) -> String {
};
let bytes = encoded
.as_bytes()
- .chunks_exact(2)
+ .as_chunks::<2>()
+ .0
+ .iter()
.map(|pair| {
let hex = std::str::from_utf8(pair).ok()?;
u8::from_str_radix(hex, 16).ok()
diff --git a/crates/openhuman-core/src/channels/callback_slot_tests.rs b/crates/openhuman-core/src/channels/callback_slot_tests.rs
index 67570c5d95..f7b3822d8e 100644
--- a/crates/openhuman-core/src/channels/callback_slot_tests.rs
+++ b/crates/openhuman-core/src/channels/callback_slot_tests.rs
@@ -97,14 +97,12 @@ async fn reactions_and_threads_without_a_callback_answer_the_unavailable_sentine
let reaction = backend
.send_reaction(&channels, "telegram", serde_json::json!({"emoji": "+1"}))
.await
- .err()
- .expect("no callback");
+ .expect_err("no callback");
assert!(reaction.to_string().starts_with(sentinel), "{reaction}");
let listed = backend
.list_threads(&channels, "telegram", None)
.await
- .err()
- .expect("no callback");
+ .expect_err("no callback");
assert!(listed.to_string().starts_with(sentinel), "{listed}");
}
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
index bf6d113625..0d099c9cc5 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/helpers_tests.rs
@@ -107,6 +107,8 @@ async fn typing_task_runs_under_the_handed_context_not_the_active_one() {
let channel = Arc::new(ProbeTyping(std::sync::Mutex::new(Some(sender))));
let cancellation = tokio_util::sync::CancellationToken::new();
// The caller's own scope is Ravi's; the typing task was handed Asha's.
+ // The scope intentionally yields the typing task handle; it is awaited below.
+ #[allow(clippy::async_yields_async)]
let waiter = CoreContext::scope(ravi, async {
spawn_typing_task(&asha, channel, "recipient".into(), cancellation.clone())
})
diff --git a/crates/openhuman-core/src/core/sentry_transport.rs b/crates/openhuman-core/src/core/sentry_transport.rs
index 030d02653f..1d46c6d966 100644
--- a/crates/openhuman-core/src/core/sentry_transport.rs
+++ b/crates/openhuman-core/src/core/sentry_transport.rs
@@ -31,13 +31,17 @@ impl SharedReqwestTransport {
if let Some(url) = options.http_proxy.as_ref() {
match reqwest::Proxy::http(url.as_ref()) {
Ok(proxy) => builder = builder.proxy(proxy),
- Err(error) => sentry_debug!("invalid HTTP proxy: {error:?}"),
+ Err(error) => {
+ sentry_debug!("invalid HTTP proxy: {error:?}");
+ }
}
}
if let Some(url) = options.https_proxy.as_ref() {
match reqwest::Proxy::https(url.as_ref()) {
Ok(proxy) => builder = builder.proxy(proxy),
- Err(error) => sentry_debug!("invalid HTTPS proxy: {error:?}"),
+ Err(error) => {
+ sentry_debug!("invalid HTTPS proxy: {error:?}");
+ }
}
}
let client = builder
@@ -111,7 +115,9 @@ impl SharedReqwestTransport {
sentry_debug!("Sentry envelope rejected as too large");
}
}
- Err(error) => sentry_debug!("failed to send Sentry envelope: {error}"),
+ Err(error) => {
+ sentry_debug!("failed to send Sentry envelope: {error}");
+ }
}
}
})
diff --git a/crates/openhuman-core/src/inference/registry_tests.rs b/crates/openhuman-core/src/inference/registry_tests.rs
index 8c4c6cd81d..158c0dea84 100644
--- a/crates/openhuman-core/src/inference/registry_tests.rs
+++ b/crates/openhuman-core/src/inference/registry_tests.rs
@@ -21,7 +21,9 @@ impl ChatModel<()> for FakeModel {
}
}
-fn fake_entry(seen: Arc<Mutex<Vec<(String, Option<String>, Option<String>)>>>) -> ChatModelEntry {
+type SeenRequests = Arc<Mutex<Vec<(String, Option<String>, Option<String>)>>>;
+
+fn fake_entry(seen: SeenRequests) -> ChatModelEntry {
ChatModelEntry {
build: Arc::new(move |request| {
seen.lock().unwrap().push((
diff --git a/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
index e7b33bbaa9..7aea8a40d5 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/schemas_tests.rs
@@ -179,7 +179,8 @@ async fn every_tokenjuice_method_answers_component_disabled_when_juice_is_off()
let mut set = crate::core::runtime::ComponentSet::all();
set.juice = false;
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(set);
- let handlers: [fn(DispatchCtx, Map<String, Value>) -> ControllerFuture; 8] = [
+ type Handler = fn(DispatchCtx, Map<String, Value>) -> ControllerFuture;
+ let handlers: [Handler; 8] = [
handle_detect,
handle_compress,
handle_cache_stats,
diff --git a/crates/openhuman-core/src/sandbox/native_jail_tests.rs b/crates/openhuman-core/src/sandbox/native_jail_tests.rs
index 0a11ed1e8a..43ba95590d 100644
--- a/crates/openhuman-core/src/sandbox/native_jail_tests.rs
+++ b/crates/openhuman-core/src/sandbox/native_jail_tests.rs
@@ -264,7 +264,7 @@ fn openhumans_own_credential_files_are_denied_when_present() {
let denied = credential_denials(
crate::security::credentials::credential_files(&config),
root.path(),
- &[scratch.clone()],
+ std::slice::from_ref(&scratch),
)
.unwrap();
diff --git a/crates/openhuman-core/src/sandbox/schemas_tests.rs b/crates/openhuman-core/src/sandbox/schemas_tests.rs
index 4e710396cf..a1c627bf49 100644
--- a/crates/openhuman-core/src/sandbox/schemas_tests.rs
+++ b/crates/openhuman-core/src/sandbox/schemas_tests.rs
@@ -226,7 +226,8 @@ async fn every_sandbox_method_answers_component_disabled_when_sandbox_is_off() {
let mut set = crate::core::runtime::ComponentSet::all();
set.sandbox = false;
let ctx = crate::core::runtime::context::CoreContext::for_test_with_components(set);
- let handlers: [fn(DispatchCtx, Map<String, Value>) -> ControllerFuture; 4] = [
+ type Handler = fn(DispatchCtx, Map<String, Value>) -> ControllerFuture;
+ let handlers: [Handler; 4] = [
handle_status,
handle_resolve_policy,
handle_cleanup_orphans,
diff --git a/crates/openhuman-core/src/skills/catalog/test_fixtures.rs b/crates/openhuman-core/src/skills/catalog/test_fixtures.rs
index ee53a7b5d6..0febe6006b 100644
--- a/crates/openhuman-core/src/skills/catalog/test_fixtures.rs
+++ b/crates/openhuman-core/src/skills/catalog/test_fixtures.rs
@@ -70,7 +70,7 @@ async fn document_route(
}
let blocked = state
.blocked_documents
- .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |left| {
+ .try_update(Ordering::SeqCst, Ordering::SeqCst, |left| {
left.checked_sub(1)
})
.is_ok();
diff --git a/crates/openhuman-core/src/web3/wallet/test_support.rs b/crates/openhuman-core/src/web3/wallet/test_support.rs
index 433eab91ca..9de787991d 100644
--- a/crates/openhuman-core/src/web3/wallet/test_support.rs
+++ b/crates/openhuman-core/src/web3/wallet/test_support.rs
@@ -128,7 +128,7 @@ pub(crate) async fn setup_wallet_in(
.await?
.value;
setup(
- &ctx,
+ ctx,
WalletSetupParams {
consent_granted: true,
source: WalletSetupSource::Imported,