Skip to content

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

test: add unit tests for agent bus, events, media, wallet, and approval

Steven Enamakel5d456dae3885
diff --git a/crates/openhuman-core/src/agent/bus_tests.rs b/crates/openhuman-core/src/agent/bus_tests.rs
index a7b3257808..16e5994922 100644
--- a/crates/openhuman-core/src/agent/bus_tests.rs
+++ b/crates/openhuman-core/src/agent/bus_tests.rs
@@ -28,6 +28,7 @@ fn test_request() -> AgentTurnRequest {
extra_tools: Vec::new(),
on_progress: None,
origin: AgentTurnOrigin::Cli,
+ approval: Default::default(),
}
}
diff --git a/crates/openhuman-core/src/core/events_tests.rs b/crates/openhuman-core/src/core/events_tests.rs
index 1a7a14139c..0298859e50 100644
--- a/crates/openhuman-core/src/core/events_tests.rs
+++ b/crates/openhuman-core/src/core/events_tests.rs
@@ -100,6 +100,8 @@ fn all_variants_have_correct_domain() {
key: "k".into(),
category: "c".into(),
namespace: "n".into(),
+ thread_id: None,
+ client_id: None,
},
"memory",
),
@@ -107,6 +109,8 @@ fn all_variants_have_correct_domain() {
DomainEvent::MemoryRecalled {
query: "q".into(),
hit_count: 0,
+ thread_id: None,
+ client_id: None,
},
"memory",
),
diff --git a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
index 06bb1b7c19..a37f7edbb7 100644
--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs
@@ -254,7 +254,7 @@ async fn per_call_observer_reports_each_calls_own_job_state() {
root.path().join("workspace"),
root.path().join("Files"),
)
- .with_per_call_inner(move |observer| PollingTool {
+ .with_per_call_inner(move |observer, _chat| PollingTool {
observer,
state: states.lock().unwrap().pop().unwrap(),
});
diff --git a/crates/openhuman-core/src/modules/wallet_host_tests.rs b/crates/openhuman-core/src/modules/wallet_host_tests.rs
index 361a3c24a6..6e55e0cf72 100644
--- a/crates/openhuman-core/src/modules/wallet_host_tests.rs
+++ b/crates/openhuman-core/src/modules/wallet_host_tests.rs
@@ -23,19 +23,29 @@ fn x402_approval_is_bound_to_the_exact_chat_owner_and_payment_facts() {
client_id: "client-1".into(),
}),
};
- let context = crate::security::approval::ApprovalChatContext {
- thread_id: "thread-1".into(),
- client_id: "client-1".into(),
+ let origin = |thread: &str, client: &str| crate::agent::turn_origin::AgentTurnOrigin::WebChat {
+ thread_id: thread.into(),
+ client_id: client.into(),
request_id: Some("request-1".into()),
};
- assert!(x402_request_owner_matches(&request, &context));
-
- let mut other_client = context.clone();
- other_client.client_id = "client-2".into();
- assert!(!x402_request_owner_matches(&request, &other_client));
- let mut other_thread = context.clone();
- other_thread.thread_id = "thread-2".into();
- assert!(!x402_request_owner_matches(&request, &other_thread));
+ assert!(x402_request_owner_matches(
+ &request,
+ Some(&origin("thread-1", "client-1"))
+ ));
+ assert!(!x402_request_owner_matches(
+ &request,
+ Some(&origin("thread-1", "client-2"))
+ ));
+ assert!(!x402_request_owner_matches(
+ &request,
+ Some(&origin("thread-2", "client-1"))
+ ));
+ // Only a WebChat turn can own an x402 payment: another origin, or none, never matches.
+ assert!(!x402_request_owner_matches(
+ &request,
+ Some(&crate::agent::turn_origin::AgentTurnOrigin::Cli)
+ ));
+ assert!(!x402_request_owner_matches(&request, None));
assert_eq!(
x402_approval_facts(&request),
diff --git a/crates/openhuman-core/src/security/approval/gate_triage_tests.rs b/crates/openhuman-core/src/security/approval/gate_triage_tests.rs
index 82d0ddc1ef..1cf5203592 100644
--- a/crates/openhuman-core/src/security/approval/gate_triage_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_triage_tests.rs
@@ -53,10 +53,11 @@ async fn a_remote_triage_escalation_parks_with_an_audit_row_rather_than_an_unkno
// `Box::pin` + a short timeout drives the future into the park without
// waiting out the TTL; nothing decides it, so it must still be pending.
+ let turn = ApprovalTurnContext::default();
let mut fut = Box::pin(turn_origin::with_origin(
remote_trigger_origin(&envelope),
gate.intercept(
- &Default::default(),
+ &turn,
"escalate to orchestrator",
"triage.escalate",
serde_json::json!({}),
diff --git a/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs b/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs
index 7be950e91b..7407ff523d 100644
--- a/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_ttl_and_triage_tests.rs
@@ -123,9 +123,10 @@ async fn waiter_future_dropped_mid_park_evicts_waiter_clears_routing_and_denies_
// `Box::pin` (not `tokio::pin!`) so `drop(fut)` below drops the *future
// itself* — and thus the `WaiterGuard` saved in its async state — rather
// than just a `Pin<&mut _>` reference.
+ let turn = ApprovalTurnContext::chat(chat_ctx());
let mut fut = Box::pin(turn_origin::with_origin(
web_origin(),
- g.intercept(&ApprovalTurnContext::chat(chat_ctx()), "shell", "run rm", serde_json::json!({})),
+ g.intercept(&turn, "shell", "run rm", serde_json::json!({})),
));
// Poll it just long enough to register the waiter, persist the pending