Skip to content

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

test(integrations): cover integration registration and web3 client

Steven Enamakel80420c8b17a7
diff --git a/crates/openhuman-tinyhumans/src/integrations/mod_tests.rs b/crates/openhuman-tinyhumans/src/integrations/mod_tests.rs
index 6c69dc7008..0b7f95d952 100644
--- a/crates/openhuman-tinyhumans/src/integrations/mod_tests.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/mod_tests.rs
@@ -50,3 +50,29 @@ fn build_client_returns_none_when_no_auth_token() {
};
assert!(build_client(&config).is_none());
}
+
+#[test]
+fn register_plugs_every_hosted_integration_into_the_core_registries() {
+ use openhuman_embed::__host::composio::{
+ unregister_composio_route_builder, unregister_proxy_target,
+ };
+ use openhuman_embed::__host::config::schema::COMPOSIO_MODE_BACKEND;
+ use openhuman_embed::__host::tool_sources::unregister_tool_source;
+
+ register(&InstallOptions::default());
+
+ assert!(unregister_tool_source(FILE_STORAGE_SOURCE_ID));
+ assert!(unregister_tool_source(INTEGRATION_TOOLS_SOURCE_ID));
+ #[cfg(feature = "media")]
+ assert!(unregister_tool_source(media::TOOL_SOURCE_ID));
+ #[cfg(feature = "web3")]
+ assert!(openhuman_embed::__host::wallet_backend::unregister_wallet_backend(web3::HANDLER_ID));
+ assert!(unregister_composio_route_builder(COMPOSIO_MODE_BACKEND));
+ assert!(unregister_proxy_target(COMPOSIO_MODE_BACKEND));
+
+ // Registration is idempotent and restores everything it removed above.
+ register(&InstallOptions::default());
+ register(&InstallOptions::default());
+ assert!(unregister_tool_source(FILE_STORAGE_SOURCE_ID));
+ register(&InstallOptions::default());
+}
diff --git a/crates/openhuman-tinyhumans/src/integrations/web3/client.rs b/crates/openhuman-tinyhumans/src/integrations/web3/client.rs
index 96e06573c2..c766ec8363 100644
--- a/crates/openhuman-tinyhumans/src/integrations/web3/client.rs
+++ b/crates/openhuman-tinyhumans/src/integrations/web3/client.rs
@@ -83,3 +83,7 @@ impl CryptoClient {
.map_err(|e| format!("web3 bridge quote failed: {e}"))
}
}
+
+#[cfg(test)]
+#[path = "client_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-tinyhumans/src/integrations/web3/client_tests.rs b/crates/openhuman-tinyhumans/src/integrations/web3/client_tests.rs
new file mode 100644
index 0000000000..f92ba69a23
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/integrations/web3/client_tests.rs
@@ -0,0 +1,65 @@
+use super::*;
+use axum::routing::{get, post};
+use axum::{Json, Router};
+use openhuman_embed::__host::config::Config;
+use serde_json::json;
+use std::sync::Arc;
+
+async fn start_mock_backend(app: Router) -> String {
+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
+ let addr = listener.local_addr().unwrap();
+ tokio::spawn(async move {
+ axum::serve(listener, app).await.unwrap();
+ });
+ format!("http://127.0.0.1:{}", addr.port())
+}
+
+#[test]
+fn from_config_errors_without_a_backend_credential() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = Config {
+ workspace_dir: tmp.path().join("workspace"),
+ config_path: tmp.path().join("config.toml"),
+ ..Config::default()
+ };
+ let error = CryptoClient::from_config(&config)
+ .err()
+ .expect("no credential, no client");
+ assert!(error.contains("signed-in session"), "{error}");
+}
+
+#[tokio::test]
+async fn routes_swap_and_bridge_hit_the_crypto_routes_and_unwrap_the_envelope() {
+ let app = Router::new()
+ .route(
+ "/agent-integrations/crypto/routes",
+ get(|| async { Json(json!({ "success": true, "data": { "chains": [1, 10] } })) }),
+ )
+ .route(
+ "/agent-integrations/crypto/swap",
+ post(|Json(body): Json<serde_json::Value>| async move {
+ Json(json!({ "success": true, "data": { "swap": body } }))
+ }),
+ )
+ .route(
+ "/agent-integrations/crypto/bridge",
+ post(|Json(body): Json<serde_json::Value>| async move {
+ Json(json!({ "success": true, "data": { "bridge": body } }))
+ }),
+ );
+ let base = start_mock_backend(app).await;
+ let client = CryptoClient::new(Arc::new(IntegrationClient::new(base, "test-token".into())));
+
+ assert_eq!(client.routes().await.unwrap(), json!({ "chains": [1, 10] }));
+ assert_eq!(
+ client.swap_tx(&json!({ "chainId": 1 })).await.unwrap(),
+ json!({ "swap": { "chainId": 1 } })
+ );
+ assert_eq!(
+ client
+ .bridge_tx(&json!({ "srcChainId": 1, "dstChainId": 10 }))
+ .await
+ .unwrap(),
+ json!({ "bridge": { "srcChainId": 1, "dstChainId": 10 } })
+ );
+}