Skip to content

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

test: move hosted RPC assertions out of core

Steven Enamakel891db96d73f6
diff --git a/crates/openhuman-core/src/core/jsonrpc_tests.rs b/crates/openhuman-core/src/core/jsonrpc_tests.rs
index 4ce9504f53..6bd2aaf5dc 100644
--- a/crates/openhuman-core/src/core/jsonrpc_tests.rs
+++ b/crates/openhuman-core/src/core/jsonrpc_tests.rs
@@ -595,230 +595,6 @@ fn http_schema_dump_includes_openhuman_and_core_methods() {
"schema dump should include migrated openhuman methods"
);
- assert!(
- methods
- .iter()
- .any(|m| m.method == "openhuman.billing_get_summary"),
- "schema dump should include billing methods"
- );
-
- assert!(
- methods
- .iter()
- .any(|m| m.method == "openhuman.team_list_members"),
- "schema dump should include team methods"
- );
-}
-
-#[cfg(feature = "http-server")]
-async fn invoke_hosted_method(
- method: &str,
- params: serde_json::Value,
-) -> Result<serde_json::Value, String> {
- use crate::core::runtime::{context::CoreContext, DomainSet};
-
- CoreContext::scope(
- CoreContext::for_test(DomainSet::full(), None, None),
- invoke_method(default_state(), method, params),
- )
- .await
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_get_current_plan_rejects_unknown_param() {
- let err = invoke_hosted_method(
- "openhuman.billing_get_current_plan",
- json!({ "extra": true }),
- )
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'extra'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_get_summary_rejects_unknown_param() {
- let err = invoke_hosted_method("openhuman.billing_get_summary", json!({ "extra": true }))
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'extra'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_purchase_plan_missing_plan_fails_validation() {
- let err = invoke_hosted_method("openhuman.billing_purchase_plan", json!({}))
- .await
- .expect_err("missing plan should fail");
- assert!(err.contains("missing required param 'plan'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_top_up_missing_amount_fails_validation() {
- let err = invoke_hosted_method("openhuman.billing_top_up", json!({}))
- .await
- .expect_err("missing amountUsd should fail");
- assert!(err.contains("missing required param 'amountUsd'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_top_up_rejects_unknown_param() {
- let err = invoke_hosted_method(
- "openhuman.billing_top_up",
- json!({ "amountUsd": 10.0, "unknownField": true }),
- )
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'unknownField'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_create_portal_session_rejects_unknown_param() {
- let err = invoke_hosted_method("openhuman.billing_create_portal_session", json!({ "x": 1 }))
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'x'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_list_members_missing_team_id_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_list_members", json!({}))
- .await
- .expect_err("missing teamId should fail");
- assert!(err.contains("missing required param 'teamId'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_list_members_rejects_unknown_param() {
- let err = invoke_hosted_method(
- "openhuman.team_list_members",
- json!({ "teamId": "t1", "extra": true }),
- )
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'extra'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_create_invite_missing_team_id_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_create_invite", json!({}))
- .await
- .expect_err("missing teamId should fail");
- assert!(err.contains("missing required param 'teamId'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_remove_member_missing_required_params_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_remove_member", json!({ "teamId": "t1" }))
- .await
- .expect_err("missing userId should fail");
- assert!(err.contains("missing required param 'userId'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_change_member_role_missing_role_fails_validation() {
- let err = invoke_hosted_method(
- "openhuman.team_change_member_role",
- json!({ "teamId": "t1", "userId": "u1" }),
- )
- .await
- .expect_err("missing role should fail");
- assert!(err.contains("missing required param 'role'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_create_coinbase_charge_missing_plan_fails_validation() {
- let err = invoke_hosted_method("openhuman.billing_create_coinbase_charge", json!({}))
- .await
- .expect_err("missing plan should fail");
- assert!(err.contains("missing required param 'plan'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn billing_create_coinbase_charge_rejects_unknown_param() {
- let err = invoke_hosted_method(
- "openhuman.billing_create_coinbase_charge",
- json!({ "plan": "pro", "extra": true }),
- )
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'extra'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_list_invites_missing_team_id_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_list_invites", json!({}))
- .await
- .expect_err("missing teamId should fail");
- assert!(err.contains("missing required param 'teamId'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_list_invites_rejects_unknown_param() {
- let err = invoke_hosted_method(
- "openhuman.team_list_invites",
- json!({ "teamId": "t1", "extra": true }),
- )
- .await
- .expect_err("unknown param should fail");
- assert!(err.contains("unknown param 'extra'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_revoke_invite_missing_team_id_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_revoke_invite", json!({}))
- .await
- .expect_err("missing teamId should fail");
- assert!(err.contains("missing required param 'teamId'"));
-}
-
-#[cfg(feature = "http-server")]
-#[tokio::test]
-async fn team_revoke_invite_missing_invite_id_fails_validation() {
- let err = invoke_hosted_method("openhuman.team_revoke_invite", json!({ "teamId": "t1" }))
- .await
- .expect_err("missing inviteId should fail");
- assert!(err.contains("missing required param 'inviteId'"));
-}
-
-#[tokio::test]
-#[cfg(feature = "http-server")]
-async fn schema_dump_includes_new_billing_and_team_methods() {
- let dump = build_http_schema_dump();
- let methods: Vec<&str> = dump.methods.iter().map(|m| m.method.as_str()).collect();
- for expected in &[
- "openhuman.billing_get_summary",
- "openhuman.billing_get_current_plan",
- "openhuman.billing_purchase_plan",
- "openhuman.billing_create_portal_session",
- "openhuman.billing_top_up",
- "openhuman.billing_create_coinbase_charge",
- "openhuman.team_list_members",
- "openhuman.team_create_invite",
- "openhuman.team_list_invites",
- "openhuman.team_revoke_invite",
- "openhuman.team_remove_member",
- "openhuman.team_change_member_role",
- ] {
- assert!(
- methods.contains(expected),
- "schema dump missing expected method: {expected}"
- );
- }
}
// --- helper coverage -----------------------------------------------------