Skip to content

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

test(relay): add coverage for relay param parsing

Steven Enamakel11c3c6ad70e4
diff --git a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs b/crates/openhuman-core/src/channels/providers/relay/params_tests.rs
index 7ad215132c..be01ec3992 100644
--- a/crates/openhuman-core/src/channels/providers/relay/params_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/params_tests.rs
@@ -144,3 +144,17 @@ fn the_channel_message_carries_the_relayed_facts() {
assert_eq!(msg.sender_name.as_deref(), Some("Ada"));
assert!(msg.thread_ts.is_none());
}
+
+#[test]
+fn a_constructed_message_round_trips_through_the_wire_shape() {
+ let built = RelayInboundParams::new("telegram", "-100123", "42", "m-1", "hello");
+ assert_eq!(built.client_id(), DEFAULT_RELAY_CLIENT_ID);
+ assert!(built.validate().is_ok());
+ let wire = serde_json::to_value(&built).expect("serialize");
+ // Unset optional fields stay off the wire rather than arriving as `null`.
+ assert!(wire.get("sender_name").is_none(), "{wire}");
+ assert!(wire.get("attachments").is_none(), "{wire}");
+ let back: RelayInboundParams = serde_json::from_value(wire).expect("deserialize");
+ assert_eq!(back, built);
+ assert_eq!(back.thread_id(), params().thread_id());
+}