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(web3/wallet): consolidate wallet schema tests into wire contracts
Steven Enamakela40a076cc6d4
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 930a24ea58..3b13f30795 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -1198,6 +1198,48 @@ pub fn all_http_method_schemas() -> Vec<HttpMethodSchemaDefinition> {/// pattern repeated across ~15 domains (plan.md §3/§6) — a legitimate new/// controller no longer breaks the count, but a schema/handler desync or a/// dropped op still fails.+#[cfg(test)]+pub(crate) struct SchemaFieldContract {+ pub name: &'static str,+ pub required: Option<bool>,+}++#[cfg(test)]+pub(crate) struct ControllerSchemaContract {+ pub namespace: &'static str,+ pub function: &'static str,+ pub input_count: Option<usize>,+ pub input_order: Option<&'static [&'static str]>,+ pub inputs: &'static [SchemaFieldContract],+ pub outputs: Option<&'static [&'static str]>,+}++/// Check one controller against a fixed wire contract copied from its+/// independently asserted domain schema tests.+#[cfg(test)]+pub(crate) fn assert_schema_contract(schema: &ControllerSchema, expected: &ControllerSchemaContract) {+ assert_eq!(schema.namespace, expected.namespace, "{} namespace", expected.function);+ assert_eq!(schema.function, expected.function, "schema function");+ if let Some(count) = expected.input_count {+ assert_eq!(schema.inputs.len(), count, "{}.{} input count", expected.namespace, expected.function);+ }+ if let Some(order) = expected.input_order {+ let actual: Vec<_> = schema.inputs.iter().map(|field| field.name).collect();+ assert_eq!(actual, order, "{}.{} input order", expected.namespace, expected.function);+ }+ for expected in expected.inputs {+ let field = schema.inputs.iter().find(|field| field.name == expected.name)+ .unwrap_or_else(|| panic!("{}.{} is missing input `{}`", expected.namespace, expected.function, expected.name));+ if let Some(required) = expected.required {+ assert_eq!(field.required, required, "{}.{} input `{}` requiredness", expected.namespace, expected.function, expected.name);+ }+ }+ if let Some(outputs) = expected.outputs {+ let actual: Vec<_> = schema.outputs.iter().map(|field| field.name).collect();+ assert_eq!(actual, outputs, "{}.{} output names", expected.namespace, expected.function);+ }+}+#[cfg(test)]pub(crate) fn assert_schema_controller_parity(schemas: &[ControllerSchema],diff --git a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs b/crates/openhuman-core/src/web3/wallet/schemas_tests.rsindex bbbcbae94d..3bf8ce1fba 100644--- a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs+++ b/crates/openhuman-core/src/web3/wallet/schemas_tests.rs@@ -1,105 +1,39 @@use super::*;+use crate::core::all::{assert_schema_contract, ControllerSchemaContract as Contract, SchemaFieldContract as Field};#[test]-fn all_schemas_lists_every_controller() {+fn wallet_schema_wire_contracts_are_preserved() {assert_eq!(all_wallet_controller_schemas().len(), 16);-}--#[test]-fn all_controllers_lists_every_handler() {assert_eq!(all_wallet_registered_controllers().len(), 16);-}--#[test]-fn recovery_phrase_controllers_are_registered_with_the_expected_inputs() {- let generate = wallet_schemas("generate_mnemonic");- assert_eq!(generate.namespace, "wallet");- assert_eq!(- generate- .inputs- .iter()- .map(|field| field.name)- .collect::<Vec<_>>(),- vec!["wordCount"]- );-- let validate = wallet_schemas("validate_mnemonic");- assert_eq!(validate.namespace, "wallet");- assert_eq!(- validate- .inputs- .iter()- .map(|field| field.name)- .collect::<Vec<_>>(),- vec!["phrase"]- );- assert!(validate.inputs[0].required);- let derive = wallet_schemas("derive_recovery_material");- assert_eq!(- derive- .inputs- .iter()- .map(|field| field.name)- .collect::<Vec<_>>(),- vec!["phrase"]- );-}--#[test]-fn tx_status_schema_takes_chain_and_hash() {- let schema = wallet_schemas("tx_status");- let names: Vec<&str> = schema.inputs.iter().map(|f| f.name).collect();- assert_eq!(names, vec!["chain", "hash", "evmNetwork"]);-}--#[test]-fn removed_swap_controller_maps_to_unknown() {- assert_eq!(wallet_schemas("prepare_swap").function, "unknown");- assert_eq!(wallet_schemas("prepare_contract_call").function, "unknown");-}--#[test]-fn status_schema_is_empty_input() {- let schema = wallet_schemas("status");- assert_eq!(schema.namespace, "wallet");- assert_eq!(schema.function, "status");- assert!(schema.inputs.is_empty());-}--#[test]-fn setup_schema_requires_all_inputs() {- let schema = wallet_schemas("setup");- // 5 original fields + 1 optional `force` field = 6 total- assert_eq!(schema.inputs.len(), 6);- let encrypted = schema- .inputs- .iter()- .find(|field| field.name == "encryptedMnemonic")- .expect("encryptedMnemonic input present");- assert!(encrypted.required);- let force = schema- .inputs- .iter()- .find(|field| field.name == "force")- .expect("force input present");- assert!(!force.required, "force must be optional");-}--#[test]-fn execute_prepared_schema_takes_quote_id_and_confirmed() {- let schema = wallet_schemas("execute_prepared");- let names: Vec<&str> = schema.inputs.iter().map(|f| f.name).collect();- assert_eq!(names, vec!["quoteId", "confirmed"]);-}--#[test]-fn prepare_transfer_schema_marks_asset_symbol_optional() {- let schema = wallet_schemas("prepare_transfer");- let asset = schema- .inputs- .iter()- .find(|f| f.name == "assetSymbol")- .expect("assetSymbol input present");- assert!(!asset.required);+ let contracts: &[(&str, Option<&[&str]>, Option<usize>, &[Field])] = &[+ ("generate_mnemonic", Some(&["wordCount"][..]), None, &[]),+ ("validate_mnemonic", Some(&["phrase"][..]), None, &[Field { name: "phrase", required: Some(true) }]),+ ("derive_recovery_material", Some(&["phrase"][..]), None, &[]),+ ("tx_status", Some(&["chain", "hash", "evmNetwork"][..]), None, &[]),+ ("status", None, Some(0), &[]),+ ("setup", None, Some(6), &[+ Field { name: "encryptedMnemonic", required: Some(true) },+ Field { name: "force", required: Some(false) },+ ]),+ ("execute_prepared", Some(&["quoteId", "confirmed"][..]), None, &[]),+ ("prepare_transfer", None, None, &[Field { name: "assetSymbol", required: Some(false) }]),+ ];+ for (function, input_order, input_count, inputs) in contracts {+ let contract = Contract {+ namespace: "wallet",+ function: *function,+ input_count: *input_count,+ input_order: *input_order,+ inputs: *inputs,+ outputs: None,+ };+ let schema = wallet_schemas(function);+ assert_ne!(schema.function, "unknown", "missing {}", contract.function);+ assert_schema_contract(&schema, &contract);+ }++ for removed in ["prepare_swap", "prepare_contract_call"] {+ assert_eq!(wallet_schemas(removed).function, "unknown");+ }}