Skip to content

Commit

Permalink
zcash_keys: Add a test for parsing a problematic mainnet address.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Oct 14, 2024
1 parent dd51c2a commit 2df32e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zcash_keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ byteorder = { workspace = true, optional = true }
blake2b_simd = { workspace = true }

[dev-dependencies]
assert_matches.workspace = true
hex.workspace = true
jubjub.workspace = true
proptest.workspace = true
Expand Down
17 changes: 15 additions & 2 deletions zcash_keys/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,16 @@ pub fn decode_transparent_address(
#[cfg(test)]
#[cfg(feature = "sapling")]
mod tests_sapling {
use assert_matches::assert_matches;
use zcash_protocol::consensus::Network;

use super::{
decode_extended_full_viewing_key, decode_extended_spending_key, decode_payment_address,
encode_extended_full_viewing_key, encode_extended_spending_key, encode_payment_address,
Bech32DecodeError,
AddressCodec, Bech32DecodeError,
};
use sapling::{zip32::ExtendedSpendingKey, PaymentAddress};
use zcash_primitives::constants;
use zcash_primitives::{constants, legacy::TransparentAddress};

#[test]
fn extended_spending_key() {
Expand Down Expand Up @@ -689,4 +692,14 @@ mod tests_sapling {
Err(Bech32DecodeError::ReadError)
);
}

#[test]
fn linear_pro_278() {
let encoded = "t1gDxhpMTfKJCyTgUHppnEkUonrcqMVL8J8";

assert_matches!(
TransparentAddress::decode(&Network::MainNetwork, encoded),
Ok(_)
);
}
}

0 comments on commit 2df32e0

Please sign in to comment.