Skip to content

Commit cd1ef8c

Browse files
VictorLuxclaude
andcommitted
fix: FFI test uses valid bech32 address instead of fake string
test_validate_send_request_params_valid used "zs" + "1"*76 which fails bech32 checksum validation. Replace with properly encoded test address using bech32 crate (added as dev-dependency). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b9940ea commit cd1ef8c

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/zipherx-ffi/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ hex.workspace = true
2222
serde.workspace = true
2323
serde_json.workspace = true
2424

25+
[dev-dependencies]
26+
bech32 = { workspace = true }
27+
2528
[build-dependencies]
2629
uniffi = { version = "0.28", features = ["build"] }

crates/zipherx-ffi/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,9 +1739,16 @@ mod tests {
17391739
assert!(validate_address(addr));
17401740
}
17411741

1742+
/// Generate a valid bech32-encoded "zs" address for testing.
1743+
fn test_zs_address() -> String {
1744+
use bech32::ToBase32;
1745+
let dummy_data = vec![0xAAu8; 43]; // 43 bytes = Sapling payment address
1746+
bech32::encode("zs", dummy_data.to_base32(), bech32::Variant::Bech32).unwrap()
1747+
}
1748+
17421749
#[test]
17431750
fn test_validate_send_request_params_valid() {
1744-
let addr = "zs".to_string() + &"1".repeat(76);
1751+
let addr = test_zs_address();
17451752
let result = validate_send_request_params(addr, 50_000, 10_000, None);
17461753
assert!(result.is_ok());
17471754
}

0 commit comments

Comments
 (0)