Fix test compilation errors related to UFVK construction.
This commit is contained in:
parent
574ca4e180
commit
7d873e9d79
|
@ -224,6 +224,7 @@ pub mod transparent {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DerivationError {
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
Transparent(hdwallet::error::Error),
|
||||
|
@ -277,14 +278,14 @@ impl UnifiedSpendingKey {
|
|||
/// Returns the transparent component of the unified key at the
|
||||
/// BIP44 path `m/44'/<coin_type>'/<account>'`.
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
pub fn transparent(&self) -> Option<&transparent::AccountPrivKey> {
|
||||
Some(&self.transparent)
|
||||
pub fn transparent(&self) -> &transparent::AccountPrivKey {
|
||||
&self.transparent
|
||||
}
|
||||
|
||||
/// Returns the Sapling extended full viewing key component of this
|
||||
/// unified key.
|
||||
pub fn sapling(&self) -> Option<&sapling::ExtendedSpendingKey> {
|
||||
Some(&self.sapling)
|
||||
pub fn sapling(&self) -> &sapling::ExtendedSpendingKey {
|
||||
&self.sapling
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -760,22 +760,27 @@ mod tests {
|
|||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let tkey = Some(
|
||||
transparent::AccountPrivKey::from_seed(&network(), &seed, AccountId(0))
|
||||
.unwrap()
|
||||
.to_account_pubkey(),
|
||||
);
|
||||
{
|
||||
let tkey = Some(
|
||||
transparent::AccountPrivKey::from_seed(&network(), &seed, AccountId(0))
|
||||
.unwrap()
|
||||
.to_account_pubkey(),
|
||||
);
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), tkey.clone(), Some(extfvk.clone()))
|
||||
.unwrap();
|
||||
init_accounts_table(db_data, &[ufvk]).unwrap();
|
||||
(
|
||||
extfvk,
|
||||
tkey.map(|k| k.to_external_pubkey(0).unwrap().to_address()),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let tkey = None;
|
||||
|
||||
let ufvk =
|
||||
UnifiedFullViewingKey::new(AccountId(0), tkey.clone(), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(db_data, &[ufvk]).unwrap();
|
||||
(
|
||||
extfvk,
|
||||
tkey.map(|k| k.to_external_pubkey(0).unwrap().to_address()),
|
||||
)
|
||||
{
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(db_data, &[ufvk]).unwrap();
|
||||
(extfvk, None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a fake CompactBlock at the given height, containing a single output paying
|
||||
|
|
|
@ -285,7 +285,7 @@ pub fn init_blocks_table<P>(
|
|||
mod tests {
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
use zcash_client_backend::keys::{sapling, UnifiedFullViewingKey};
|
||||
use zcash_client_backend::keys::{sapling, UnifiedFullViewingKey, UnifiedSpendingKey};
|
||||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
use zcash_client_backend::keys::transparent;
|
||||
|
@ -322,15 +322,19 @@ mod tests {
|
|||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let tkey = Some(
|
||||
transparent::AccountPrivKey::from_seed(&network(), &seed, account)
|
||||
.unwrap()
|
||||
.to_account_pubkey(),
|
||||
);
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let tkey = None;
|
||||
let ufvk = UnifiedFullViewingKey::new(
|
||||
account,
|
||||
Some(
|
||||
transparent::AccountPrivKey::from_seed(&network(), &seed, account)
|
||||
.unwrap()
|
||||
.to_account_pubkey(),
|
||||
),
|
||||
Some(extfvk),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let ufvk = UnifiedFullViewingKey::new(account, tkey, Some(extfvk)).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(account, Some(extfvk)).unwrap();
|
||||
|
||||
init_accounts_table(&db_data, &[ufvk.clone()]).unwrap();
|
||||
|
||||
|
@ -375,13 +379,14 @@ mod tests {
|
|||
let seed = [0u8; 32];
|
||||
|
||||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&seed, network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk)).unwrap();
|
||||
let account_id = AccountId(0);
|
||||
let usk = UnifiedSpendingKey::from_seed(&tests::network(), &seed, account_id).unwrap();
|
||||
let ufvk = usk.to_unified_full_viewing_key();
|
||||
let expected_address = ufvk.sapling().unwrap().default_address().1;
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
|
||||
// The account's address should be in the data DB
|
||||
let pa = get_address(&db_data, AccountId(0)).unwrap();
|
||||
assert_eq!(pa.unwrap(), extsk.default_address().1);
|
||||
assert_eq!(pa.unwrap(), expected_address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,8 +225,8 @@ mod tests {
|
|||
};
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvks = [
|
||||
UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk0)).unwrap(),
|
||||
UnifiedFullViewingKey::new(AccountId(1), None, Some(extfvk1)).unwrap(),
|
||||
UnifiedFullViewingKey::new(AccountId(0), Some(extfvk0)).unwrap(),
|
||||
UnifiedFullViewingKey::new(AccountId(1), Some(extfvk1)).unwrap(),
|
||||
];
|
||||
|
||||
init_accounts_table(&db_data, &ufvks).unwrap();
|
||||
|
@ -276,7 +276,11 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk)).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk)).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
let to = extsk.default_address().1.into();
|
||||
|
||||
|
@ -316,7 +320,10 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk)).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk)).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
let to = extsk.default_address().1.into();
|
||||
|
||||
|
@ -358,7 +365,10 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk.clone())).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
|
||||
// Add funds to the wallet in a single note
|
||||
|
@ -498,7 +508,10 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk.clone())).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
|
||||
// Add funds to the wallet in a single note
|
||||
|
@ -624,7 +637,10 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network.coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk.clone())).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
|
||||
// Add funds to the wallet in a single note
|
||||
|
@ -731,7 +747,10 @@ mod tests {
|
|||
// Add an account to the wallet
|
||||
let extsk = sapling::spending_key(&[0u8; 32], network().coin_type(), AccountId(0));
|
||||
let extfvk = ExtendedFullViewingKey::from(&extsk);
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), None, Some(extfvk.clone())).unwrap();
|
||||
#[cfg(not(feature = "transparent-inputs"))]
|
||||
let ufvk = UnifiedFullViewingKey::new(AccountId(0), Some(extfvk.clone())).unwrap();
|
||||
init_accounts_table(&db_data, &[ufvk]).unwrap();
|
||||
|
||||
// Add funds to the wallet in a single note
|
||||
|
|
Loading…
Reference in New Issue