Update unified address test vectors

This commit is contained in:
Kris Nuttycombe 2022-02-11 13:49:38 -07:00
parent 43d052d9d8
commit 990b0afe5d
2 changed files with 773 additions and 296 deletions

View File

@ -3,14 +3,14 @@ use std::iter;
use crate::{
unified::{
self,
address::{test_vectors::TEST_VECTORS, Receiver},
address::{test_vectors::test_vectors, Receiver},
},
Network, ToAddress, ZcashAddress,
};
#[test]
fn unified() {
for tv in TEST_VECTORS {
for tv in test_vectors() {
// Double-check test vectors match requirements:
// - Only one of P2PKH and P2SH.
assert!(tv.p2pkh_bytes.is_none() || tv.p2sh_bytes.is_none());
@ -19,11 +19,16 @@ fn unified() {
let addr_string = String::from_utf8(tv.unified_addr.to_vec()).unwrap();
let unknown_tc = tv.unknown_typecode;
let receivers = iter::empty()
.chain(tv.p2pkh_bytes.map(Receiver::P2pkh))
.chain(tv.p2sh_bytes.map(Receiver::P2sh))
.chain(tv.sapling_raw_addr.map(Receiver::Sapling))
.chain(tv.orchard_raw_addr.map(Receiver::Orchard))
.chain(tv.unknown_bytes.map(|data| Receiver::Unknown {
typecode: unknown_tc,
data,
}))
.collect();
let expected_addr = ZcashAddress::from_unified(Network::Main, unified::Address(receivers));