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(wallet): strengthen wallet schema contract assertions
Steven Enamakelb2042703d179
diff --git a/crates/openhuman-core/src/core/all_tests.rs b/crates/openhuman-core/src/core/all_tests.rsindex d2c2debf23..06d670e421 100644--- a/crates/openhuman-core/src/core/all_tests.rs+++ b/crates/openhuman-core/src/core/all_tests.rs@@ -112,10 +112,21 @@ fn registered_controller_schemas_are_consistent_and_serializable() {let schema = &controller.schema;let method = schema.method_name();assert!(methods.insert(method.clone()), "duplicate method {method}");+ assert!(!schema.namespace.trim().is_empty(), "{method} has no namespace");+ assert!(!schema.function.trim().is_empty(), "{method} has no function name");assert!(!schema.description.trim().is_empty(),"{method} has no description");+ assert!(!schema.outputs.is_empty(), "{method} has no output fields");++ if method == "openhuman.wallet_setup" {+ assert_eq!(+ required_input_contract(schema, &["encryptedMnemonic"]),+ Ok(()),+ "wallet.setup required-input contract"+ );+ }let serialized = serde_json::to_value(schema).expect("controller schema serializes");let serialized_inputs = serialized["inputs"]diff --git a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs b/crates/openhuman-core/src/web3/wallet/schemas_tests.rsindex a3f629aaf7..3c659f1189 100644--- a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs+++ b/crates/openhuman-core/src/web3/wallet/schemas_tests.rs@@ -1,5 +1,8 @@use super::*;-use crate::core::all::{expect_schema_fields, expect_schema_input_order};+use crate::core::all::{+ expect_schema_fields, expect_schema_identity, expect_schema_input_order,+ expect_schema_required_inputs, required_input_contract,+};#[test]fn wallet_schema_wire_contracts_are_preserved() {@@ -13,9 +16,14 @@ fn wallet_schema_wire_contracts_are_preserved() {("tx_status", &["chain", "hash", "evmNetwork"][..]),("execute_prepared", &["quoteId", "confirmed"][..]),] {- expect_schema_input_order(&wallet_schemas(function), inputs);+ let schema = wallet_schemas(function);+ expect_schema_input_order(&schema, inputs);+ if matches!(function, "generate_mnemonic" | "validate_mnemonic") {+ expect_schema_identity(&schema, "wallet", function);+ }}let status = wallet_schemas("status");+ expect_schema_identity(&status, "wallet", "status");assert!(status.inputs.is_empty());let setup = wallet_schemas("setup");assert_eq!(setup.inputs.len(), 6);@@ -31,7 +39,49 @@ fn wallet_schema_wire_contracts_are_preserved() {&wallet_schemas("prepare_transfer"),&[("assetSymbol", Some(false))],);+ expect_schema_required_inputs(&setup, &["encryptedMnemonic"]);for removed in ["prepare_swap", "prepare_contract_call"] {assert_eq!(wallet_schemas(removed).function, "unknown");}}++#[test]+fn required_input_contract_rejects_removed_or_optional_encrypted_mnemonic() {+ let registered = all_wallet_registered_controllers()+ .into_iter()+ .find(|controller| controller.schema.function == "setup")+ .expect("wallet.setup is registered");+ let schema = ®istered.schema;+ expect_schema_identity(schema, "wallet", "setup");+ assert!(+ schema+ .inputs+ .iter()+ .any(|input| input.name == "encryptedMnemonic"),+ "fixed contract field must exist before mutation"+ );+ assert_eq!(+ required_input_contract(schema, &["encryptedMnemonic"]),+ Ok(()),+ "real registered wallet.setup schema satisfies the independent oracle"+ );++ let mut removed = schema.clone();+ removed+ .inputs+ .retain(|input| input.name != "encryptedMnemonic");+ assert!(required_input_contract(&removed, &["encryptedMnemonic"])+ .unwrap_err()+ .contains("expected [\"encryptedMnemonic\"], got []"));++ let mut optional = schema.clone();+ optional+ .inputs+ .iter_mut()+ .find(|input| input.name == "encryptedMnemonic")+ .expect("asserted field exists")+ .required = false;+ assert!(required_input_contract(&optional, &["encryptedMnemonic"])+ .unwrap_err()+ .contains("expected [\"encryptedMnemonic\"], got []"));+}