The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(relay): migrate relay tests to typed channel messages
Steven Enamakel87d3a8ecfd7c
diff --git a/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs b/crates/openhuman-core/src/channels/providers/relay/channel_tests.rsindex cc372029d9..9af1b5a718 100644--- a/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/channel_tests.rs@@ -11,9 +11,15 @@ fn sink() -> RelayChannel {)}+fn text_message(text: &str, recipient: &str) -> tinychannels_bus::ChannelOutboundMessage {+ crate::channels::outbound::text_message("telegram", recipient, text, None)+}+#[test]fn the_outbound_event_names_the_chat_and_carries_the_text() {- let event = sink().outbound_event(&SendMessage::new("hi there", "-100"));+ let event = sink()+ .outbound_event(&text_message("hi there", "-100"))+ .unwrap();assert_eq!(event.event, CHANNEL_OUTBOUND_EVENT);assert_eq!(event.client_id, "gw-1");assert_eq!(event.thread_id, "channel:telegram/42/-100");@@ -27,8 +33,12 @@ fn the_outbound_event_names_the_chat_and_carries_the_text() {assert!(event.agent.is_none(), "stamped at publish, not here");assert!(event.profile.is_none(), "stamped at publish, not here");- let wire = serde_json::to_value(sink().outbound_event(&SendMessage::new("x", "-100")))- .expect("serialize");+ let wire = serde_json::to_value(+ sink()+ .outbound_event(&text_message("x", "-100"))+ .expect("event"),+ )+ .expect("serialize");assert!(wire.get("agent").is_none(),"the routing stamp is not on the wire"@@ -59,7 +69,7 @@ async fn send_publishes_under_the_callers_stamp_and_records_the_text() {let sender = Arc::clone(&channel);crate::core::runtime::CoreContext::scope(context, async move {sender- .send(&SendMessage::new("reply one", "2"))+ .send_typed(&text_message("reply one", "2")).await.expect("send");})@@ -84,7 +94,12 @@ async fn send_publishes_under_the_callers_stamp_and_records_the_text() {#[tokio::test]async fn a_relay_has_no_listener() {let (tx, _rx) = tokio::sync::mpsc::channel(1);- assert!(sink().listen(tx).await.is_err());+ #[allow(+ deprecated,+ reason = "TinyChannels v0.1.39 has no typed listener method for a no-listener adapter"+ )]+ let result = sink().listen(tx).await;+ assert!(result.is_err());assert_eq!(sink().name(), "telegram");assert!(!sink().supports_draft_updates());}diff --git a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs b/crates/openhuman-core/src/channels/providers/relay/params_tests.rsindex cf2ea8a660..3bb4e000c9 100644--- a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs+++ b/crates/openhuman-core/src/channels/providers/relay/params_tests.rs@@ -134,15 +134,15 @@ fn every_field_is_checked() {}#[test]-fn the_channel_message_carries_the_relayed_facts() {- let msg = params().to_channel_message();- assert_eq!(msg.channel, "telegram");- assert_eq!(msg.id, "m-1");- assert_eq!(msg.sender, "42");- assert_eq!(msg.reply_target, "-100123");- assert_eq!(msg.content, "hello");- assert_eq!(msg.sender_name.as_deref(), Some("Ada"));- assert!(msg.thread_ts.is_none());+fn the_inbound_envelope_carries_the_relayed_facts() {+ let msg = params().to_inbound_envelope();+ assert_eq!(msg.channel.id, "telegram");+ assert_eq!(msg.message_id, "m-1");+ assert_eq!(msg.sender.id, "42");+ assert_eq!(msg.conversation.id, "-100123");+ assert_eq!(msg.text, "hello");+ assert_eq!(msg.sender.name.as_deref(), Some("Ada"));+ assert!(msg.conversation.thread_id.is_none());}#[test]diff --git a/crates/openhuman-core/src/channels/runtime/test_support.rs b/crates/openhuman-core/src/channels/runtime/test_support.rsindex 1b6efbe5bb..0919d62f37 100644--- a/crates/openhuman-core/src/channels/runtime/test_support.rs+++ b/crates/openhuman-core/src/channels/runtime/test_support.rs@@ -1,9 +1,7 @@//! Debug-build harnesses for raw integration coverage of the channel runtime.pub use super::dispatch::test_support::build_channel_context_block_for_test;-use super::dispatch::{- process_channel_message, process_channel_runtime_message, RuntimeChannelMessage,-};+use super::dispatch::{process_channel_runtime_message, RuntimeChannelMessage};pub use super::startup::test_support::resolve_yuanbao_app_secret_for_test;use crate::agent::bus::{AgentTurnRequest, AgentTurnResponse, AGENT_RUN_TURN_METHOD};use crate::channels::context::{ChannelRuntimeContext, CHANNEL_MESSAGE_TIMEOUT_SECS};@@ -22,7 +20,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};use std::sync::{Arc, Mutex};use std::time::Duration;use tinychannels_bus::context::ChatMessage;-use tinychannels_bus::{ChannelInboundEnvelope, ChannelOutboundMessage, ChannelRef, ConversationRef, SenderRef};+use tinychannels_bus::{+ ChannelInboundEnvelope, ChannelOutboundMessage, ChannelRef, ConversationRef, SenderRef,+};use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};use tinytools::{Tool, ToolResult};@@ -215,10 +215,7 @@ impl Channel for HarnessChannel {deprecated,reason = "TinyChannels v0.1.39 exposes drafts only through its v21 test-double method")]- async fn send_draft(- &self,- message: &tinychannels_bus::SendMessage,- ) -> Result<Option<String>> {+ async fn send_draft(&self, message: &tinychannels_bus::SendMessage) -> Result<Option<String>> {self.state.sends.lock().await.push(ObservedSend {kind: "draft",recipient: message.recipient.clone(),@@ -478,29 +475,31 @@ pub async fn run_dispatch_harness(options: DispatchHarnessOptions) -> DispatchHalet expected_event_channel = options.channel_name.clone();- let message = options.inbound_envelope.unwrap_or_else(|| ChannelInboundEnvelope {- channel: ChannelRef {- id: options.channel_name,- account_id: None,- },- message_id: "m1".to_string(),- conversation: ConversationRef {- id: "reply".to_string(),- thread_id: options.thread_ts,+ let message = options+ .inbound_envelope+ .unwrap_or_else(|| ChannelInboundEnvelope {+ channel: ChannelRef {+ id: options.channel_name,+ account_id: None,+ },+ message_id: "m1".to_string(),+ conversation: ConversationRef {+ id: "reply".to_string(),+ thread_id: options.thread_ts,+ ..Default::default()+ },+ sender: SenderRef {+ id: "alice".to_string(),+ ..Default::default()+ },+ timestamp_unix_ms: Some(1),+ text: options.content.clone(),+ parts: vec![tinychannels_bus::channel::ContentPart::Text {+ text: options.content,+ markdown_dialect: None,+ }],..Default::default()- },- sender: SenderRef {- id: "alice".to_string(),- ..Default::default()- },- timestamp_unix_ms: Some(1),- text: options.content.clone(),- parts: vec![tinychannels_bus::channel::ContentPart::Text {- text: options.content,- markdown_dialect: None,- }],- ..Default::default()- });+ });process_channel_runtime_message(Arc::clone(&ctx),RuntimeChannelMessage::with_inbound_envelope(message),