Skip to content

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

test(web3): cover mnemonic word count validation

Steven Enamakel0761836582fd
diff --git a/Cargo.lock b/Cargo.lock
index 16a955edbb..55e6cfb3ff 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8377,7 +8377,7 @@ dependencies = [
[[package]]
name = "tinywallet"
-version = "0.19.0"
+version = "0.20.0"
dependencies = [
"coins-bip32",
"coins-bip39",
@@ -8396,7 +8396,7 @@ dependencies = [
[[package]]
name = "tinywallet-bus"
-version = "0.19.0"
+version = "0.20.0"
dependencies = [
"serde",
"serde_json",
@@ -8405,7 +8405,7 @@ dependencies = [
[[package]]
name = "tinywallet-crypto"
-version = "0.19.0"
+version = "0.20.0"
dependencies = [
"bech32 0.12.0",
"bs58",
@@ -8418,7 +8418,7 @@ dependencies = [
[[package]]
name = "tinywallet-x402"
-version = "0.19.0"
+version = "0.20.0"
[[package]]
name = "tokio"
diff --git a/crates/openhuman-core/src/web3/wallet/ops_tests.rs b/crates/openhuman-core/src/web3/wallet/ops_tests.rs
index 920c11bcf4..e435f65474 100644
--- a/crates/openhuman-core/src/web3/wallet/ops_tests.rs
+++ b/crates/openhuman-core/src/web3/wallet/ops_tests.rs
@@ -54,6 +54,25 @@ fn validate_setup_rejects_invalid_word_count() {
.contains("unsupported mnemonic word count"));
}
+#[test]
+fn word_count_validation_follows_the_wallet_contract() {
+ for count in tinywallet_bus::MNEMONIC_WORD_COUNTS {
+ let mut params = sample_params();
+ params.mnemonic_word_count = count;
+ assert!(validate_setup(&params).is_ok(), "{count} words accepted");
+ }
+ let message = supported_word_counts();
+ assert_eq!(message, "12, 15, 18, 21, 24");
+}
+
+#[tokio::test]
+async fn generate_recovery_phrase_rejects_unsupported_word_count_before_the_module() {
+ let error = generate_recovery_phrase(13)
+ .await
+ .expect_err("13 words is not a BIP-39 length");
+ assert!(error.contains("13"), "{error}");
+}
+
#[test]
fn validate_setup_rejects_missing_encrypted_mnemonic() {
let mut params = sample_params();