From 6f1e4aff1acceedd55244857901678ae1fc900a7 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 21 Mar 2024 21:06:07 -0600 Subject: [PATCH] zcash_client_sqlite: Fix tests that broke with the addition of Orchard UA receivers. --- zcash_client_sqlite/src/wallet/init.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/zcash_client_sqlite/src/wallet/init.rs b/zcash_client_sqlite/src/wallet/init.rs index 572b941cb..644f6748f 100644 --- a/zcash_client_sqlite/src/wallet/init.rs +++ b/zcash_client_sqlite/src/wallet/init.rs @@ -326,7 +326,7 @@ mod tests { address::Address, data_api::scanning::ScanPriority, encoding::{encode_extended_full_viewing_key, encode_payment_address}, - keys::{sapling, UnifiedFullViewingKey, UnifiedSpendingKey}, + keys::{sapling, UnifiedAddressRequest, UnifiedFullViewingKey, UnifiedSpendingKey}, }; use ::sapling::zip32::ExtendedFullViewingKey; @@ -338,9 +338,7 @@ mod tests { zip32::AccountId, }; - use crate::{ - testing::TestBuilder, wallet::scanning::priority_code, WalletDb, DEFAULT_UA_REQUEST, - }; + use crate::{testing::TestBuilder, wallet::scanning::priority_code, WalletDb, UA_TRANSPARENT}; use super::init_wallet_db; @@ -1360,8 +1358,12 @@ mod tests { )?; let ufvk_str = ufvk.encode(&wdb.params); + + // Unified addresses at the time of the addition of migrations did not contain an + // Orchard component. + let ua_request = UnifiedAddressRequest::unsafe_new(false, true, UA_TRANSPARENT); let address_str = Address::Unified( - ufvk.default_address(DEFAULT_UA_REQUEST) + ufvk.default_address(ua_request) .expect("A valid default address exists for the UFVK") .0, ) @@ -1381,7 +1383,7 @@ mod tests { { let taddr = Address::Transparent( *ufvk - .default_address(DEFAULT_UA_REQUEST) + .default_address(ua_request) .expect("A valid default address exists for the UFVK") .0 .transparent() @@ -1482,10 +1484,13 @@ mod tests { assert_eq!(DiversifierIndex::from(tv.diversifier_index), di); assert_eq!(tvua.transparent(), ua.transparent()); assert_eq!(tvua.sapling(), ua.sapling()); + #[cfg(not(feature = "orchard"))] assert_eq!(tv.unified_addr, ua.encode(&Network::MainNetwork)); + // hardcoded with knowledge of what's coming next + let ua_request = UnifiedAddressRequest::unsafe_new(false, true, true); db_data - .get_next_available_address(account_id, DEFAULT_UA_REQUEST) + .get_next_available_address(account_id, ua_request) .unwrap() .expect("get_next_available_address generated an address"); } else {