zcash_client_sqlite: Move testing helper functions into module
This commit is contained in:
parent
b3474724a9
commit
7ba36c7bd2
|
@ -348,7 +348,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chain::init::init_cache_database,
|
chain::init::init_cache_database,
|
||||||
tests::{
|
testing::{
|
||||||
self, fake_compact_block, fake_compact_block_spending, init_test_accounts_table,
|
self, fake_compact_block, fake_compact_block_spending, init_test_accounts_table,
|
||||||
insert_into_cache, sapling_activation_height, AddressType,
|
insert_into_cache, sapling_activation_height, AddressType,
|
||||||
},
|
},
|
||||||
|
@ -363,7 +363,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -386,7 +386,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache
|
// Scan the cache
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -409,7 +409,7 @@ mod tests {
|
||||||
// Scanning should detect no inconsistencies
|
// Scanning should detect no inconsistencies
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -426,7 +426,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -455,7 +455,7 @@ mod tests {
|
||||||
// Scanning the cache should find no inconsistencies
|
// Scanning the cache should find no inconsistencies
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -487,7 +487,7 @@ mod tests {
|
||||||
// Data+cache chain should be invalid at the data/cache boundary
|
// Data+cache chain should be invalid at the data/cache boundary
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 2,
|
sapling_activation_height() + 2,
|
||||||
|
@ -505,7 +505,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -542,7 +542,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache
|
// Scan the cache
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -584,7 +584,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache again
|
// Scan the cache again
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -606,7 +606,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -626,7 +626,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb1);
|
insert_into_cache(&db_cache, &cb1);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -660,7 +660,7 @@ mod tests {
|
||||||
insert_into_cache(&db_cache, &cb3);
|
insert_into_cache(&db_cache, &cb3);
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 2,
|
sapling_activation_height() + 2,
|
||||||
|
@ -672,7 +672,7 @@ mod tests {
|
||||||
// If we add a block of height SAPLING_ACTIVATION_HEIGHT + 1, we can now scan that
|
// If we add a block of height SAPLING_ACTIVATION_HEIGHT + 1, we can now scan that
|
||||||
insert_into_cache(&db_cache, &cb2);
|
insert_into_cache(&db_cache, &cb2);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -701,7 +701,7 @@ mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
spend(
|
spend(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
crate::wallet::sapling::tests::test_prover(),
|
crate::wallet::sapling::tests::test_prover(),
|
||||||
&input_selector,
|
&input_selector,
|
||||||
&usk,
|
&usk,
|
||||||
|
@ -720,7 +720,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -746,7 +746,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache
|
// Scan the cache
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -774,7 +774,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache again
|
// Scan the cache again
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -796,7 +796,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -822,7 +822,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache
|
// Scan the cache
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -855,7 +855,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the cache again
|
// Scan the cache again
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -877,7 +877,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -920,7 +920,7 @@ mod tests {
|
||||||
|
|
||||||
// Scan the spending block first.
|
// Scan the spending block first.
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -936,7 +936,7 @@ mod tests {
|
||||||
|
|
||||||
// Now scan the block in which we received the note that was spent.
|
// Now scan the block in which we received the note that was spent.
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
|
|
@ -90,6 +90,9 @@ pub mod serialization;
|
||||||
pub mod wallet;
|
pub mod wallet;
|
||||||
use wallet::commitment_tree::{self, put_shard_roots};
|
use wallet::commitment_tree::{self, put_shard_roots};
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod testing;
|
||||||
|
|
||||||
/// The maximum number of blocks the wallet is allowed to rewind. This is
|
/// The maximum number of blocks the wallet is allowed to rewind. This is
|
||||||
/// consistent with the bound in zcashd, and allows block data deeper than
|
/// consistent with the bound in zcashd, and allows block data deeper than
|
||||||
/// this delta from the chain tip to be pruned.
|
/// this delta from the chain tip to be pruned.
|
||||||
|
@ -1082,317 +1085,33 @@ extern crate assert_matches;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use prost::Message;
|
use zcash_client_backend::data_api::{WalletRead, WalletWrite};
|
||||||
use rand_core::{OsRng, RngCore};
|
|
||||||
use rusqlite::params;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
use std::{fs::File, path::Path};
|
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
|
||||||
use zcash_primitives::{legacy, legacy::keys::IncomingViewingKey};
|
|
||||||
|
|
||||||
use zcash_note_encryption::Domain;
|
|
||||||
use zcash_primitives::{
|
|
||||||
block::BlockHash,
|
|
||||||
consensus::{BlockHeight, Network, NetworkUpgrade, Parameters},
|
|
||||||
legacy::TransparentAddress,
|
|
||||||
memo::MemoBytes,
|
|
||||||
sapling::{
|
|
||||||
note_encryption::{sapling_note_encryption, SaplingDomain},
|
|
||||||
util::generate_random_rseed,
|
|
||||||
value::NoteValue,
|
|
||||||
Note, Nullifier, PaymentAddress,
|
|
||||||
},
|
|
||||||
transaction::components::Amount,
|
|
||||||
zip32::{sapling::DiversifiableFullViewingKey, DiversifierIndex},
|
|
||||||
};
|
|
||||||
|
|
||||||
use zcash_client_backend::{
|
|
||||||
data_api::{WalletRead, WalletWrite},
|
|
||||||
keys::{sapling, UnifiedFullViewingKey},
|
|
||||||
proto::compact_formats::{
|
|
||||||
self as compact, CompactBlock, CompactSaplingOutput, CompactSaplingSpend, CompactTx,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
wallet::init::{init_accounts_table, init_wallet_db},
|
testing::{init_test_accounts_table_ufvk, network},
|
||||||
|
wallet::init::init_wallet_db,
|
||||||
AccountId, WalletDb,
|
AccountId, WalletDb,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::BlockDb;
|
#[cfg(feature = "unstable")]
|
||||||
|
use zcash_primitives::{
|
||||||
|
block::BlockHash,
|
||||||
|
consensus::{BlockHeight, Parameters},
|
||||||
|
transaction::components::Amount,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
use super::{
|
use zcash_client_backend::keys::sapling;
|
||||||
chain::{init::init_blockmeta_db, BlockMeta},
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
|
use crate::{
|
||||||
|
chain::init::init_blockmeta_db,
|
||||||
|
testing::{fake_compact_block, store_in_fsblockdb, AddressType},
|
||||||
FsBlockDb,
|
FsBlockDb,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "mainnet")]
|
|
||||||
pub(crate) fn network() -> Network {
|
|
||||||
Network::MainNetwork
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "mainnet"))]
|
|
||||||
pub(crate) fn network() -> Network {
|
|
||||||
Network::TestNetwork
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "mainnet")]
|
|
||||||
pub(crate) fn sapling_activation_height() -> BlockHeight {
|
|
||||||
Network::MainNetwork
|
|
||||||
.activation_height(NetworkUpgrade::Sapling)
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "mainnet"))]
|
|
||||||
pub(crate) fn sapling_activation_height() -> BlockHeight {
|
|
||||||
Network::TestNetwork
|
|
||||||
.activation_height(NetworkUpgrade::Sapling)
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub(crate) fn init_test_accounts_table(
|
|
||||||
db_data: &mut WalletDb<rusqlite::Connection, Network>,
|
|
||||||
) -> (DiversifiableFullViewingKey, Option<TransparentAddress>) {
|
|
||||||
let (ufvk, taddr) = init_test_accounts_table_ufvk(db_data);
|
|
||||||
(ufvk.sapling().unwrap().clone(), taddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub(crate) fn init_test_accounts_table_ufvk(
|
|
||||||
db_data: &mut WalletDb<rusqlite::Connection, Network>,
|
|
||||||
) -> (UnifiedFullViewingKey, Option<TransparentAddress>) {
|
|
||||||
let seed = [0u8; 32];
|
|
||||||
let account = AccountId::from(0);
|
|
||||||
let extsk = sapling::spending_key(&seed, network().coin_type(), account);
|
|
||||||
let dfvk = extsk.to_diversifiable_full_viewing_key();
|
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
|
||||||
let (tkey, taddr) = {
|
|
||||||
let tkey = legacy::keys::AccountPrivKey::from_seed(&network(), &seed, account)
|
|
||||||
.unwrap()
|
|
||||||
.to_account_pubkey();
|
|
||||||
let taddr = tkey.derive_external_ivk().unwrap().default_address().0;
|
|
||||||
(Some(tkey), Some(taddr))
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "transparent-inputs"))]
|
|
||||||
let taddr = None;
|
|
||||||
|
|
||||||
let ufvk = UnifiedFullViewingKey::new(
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
|
||||||
tkey,
|
|
||||||
Some(dfvk),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let ufvks = HashMap::from([(account, ufvk.clone())]);
|
|
||||||
init_accounts_table(db_data, &ufvks).unwrap();
|
|
||||||
|
|
||||||
(ufvk, taddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) enum AddressType {
|
|
||||||
DefaultExternal,
|
|
||||||
DiversifiedExternal(DiversifierIndex),
|
|
||||||
Internal,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a fake CompactBlock at the given height, containing a single output paying
|
|
||||||
/// an address. Returns the CompactBlock and the nullifier for the new note.
|
|
||||||
pub(crate) fn fake_compact_block(
|
|
||||||
height: BlockHeight,
|
|
||||||
prev_hash: BlockHash,
|
|
||||||
dfvk: &DiversifiableFullViewingKey,
|
|
||||||
req: AddressType,
|
|
||||||
value: Amount,
|
|
||||||
initial_sapling_tree_size: u32,
|
|
||||||
) -> (CompactBlock, Nullifier) {
|
|
||||||
let to = match req {
|
|
||||||
AddressType::DefaultExternal => dfvk.default_address().1,
|
|
||||||
AddressType::DiversifiedExternal(idx) => dfvk.find_address(idx).unwrap().1,
|
|
||||||
AddressType::Internal => dfvk.change_address().1,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create a fake Note for the account
|
|
||||||
let mut rng = OsRng;
|
|
||||||
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
|
||||||
let note = Note::from_parts(to, NoteValue::from_raw(value.into()), rseed);
|
|
||||||
let encryptor = sapling_note_encryption::<_, Network>(
|
|
||||||
Some(dfvk.fvk().ovk),
|
|
||||||
note.clone(),
|
|
||||||
MemoBytes::empty(),
|
|
||||||
&mut rng,
|
|
||||||
);
|
|
||||||
let cmu = note.cmu().to_bytes().to_vec();
|
|
||||||
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
|
||||||
.0
|
|
||||||
.to_vec();
|
|
||||||
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
|
||||||
|
|
||||||
// Create a fake CompactBlock containing the note
|
|
||||||
let cout = CompactSaplingOutput {
|
|
||||||
cmu,
|
|
||||||
ephemeral_key,
|
|
||||||
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
|
||||||
};
|
|
||||||
let mut ctx = CompactTx::default();
|
|
||||||
let mut txid = vec![0; 32];
|
|
||||||
rng.fill_bytes(&mut txid);
|
|
||||||
ctx.hash = txid;
|
|
||||||
ctx.outputs.push(cout);
|
|
||||||
let mut cb = CompactBlock {
|
|
||||||
hash: {
|
|
||||||
let mut hash = vec![0; 32];
|
|
||||||
rng.fill_bytes(&mut hash);
|
|
||||||
hash
|
|
||||||
},
|
|
||||||
height: height.into(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
|
||||||
cb.vtx.push(ctx);
|
|
||||||
cb.chain_metadata = Some(compact::ChainMetadata {
|
|
||||||
sapling_commitment_tree_size: initial_sapling_tree_size
|
|
||||||
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
(cb, note.nf(&dfvk.fvk().vk.nk, 0))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a fake CompactBlock at the given height, spending a single note from the
|
|
||||||
/// given address.
|
|
||||||
pub(crate) fn fake_compact_block_spending(
|
|
||||||
height: BlockHeight,
|
|
||||||
prev_hash: BlockHash,
|
|
||||||
(nf, in_value): (Nullifier, Amount),
|
|
||||||
dfvk: &DiversifiableFullViewingKey,
|
|
||||||
to: PaymentAddress,
|
|
||||||
value: Amount,
|
|
||||||
initial_sapling_tree_size: u32,
|
|
||||||
) -> CompactBlock {
|
|
||||||
let mut rng = OsRng;
|
|
||||||
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
|
||||||
|
|
||||||
// Create a fake CompactBlock containing the note
|
|
||||||
let cspend = CompactSaplingSpend { nf: nf.to_vec() };
|
|
||||||
let mut ctx = CompactTx::default();
|
|
||||||
let mut txid = vec![0; 32];
|
|
||||||
rng.fill_bytes(&mut txid);
|
|
||||||
ctx.hash = txid;
|
|
||||||
ctx.spends.push(cspend);
|
|
||||||
|
|
||||||
// Create a fake Note for the payment
|
|
||||||
ctx.outputs.push({
|
|
||||||
let note = Note::from_parts(to, NoteValue::from_raw(value.into()), rseed);
|
|
||||||
let encryptor = sapling_note_encryption::<_, Network>(
|
|
||||||
Some(dfvk.fvk().ovk),
|
|
||||||
note.clone(),
|
|
||||||
MemoBytes::empty(),
|
|
||||||
&mut rng,
|
|
||||||
);
|
|
||||||
let cmu = note.cmu().to_bytes().to_vec();
|
|
||||||
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
|
||||||
.0
|
|
||||||
.to_vec();
|
|
||||||
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
|
||||||
|
|
||||||
CompactSaplingOutput {
|
|
||||||
cmu,
|
|
||||||
ephemeral_key,
|
|
||||||
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create a fake Note for the change
|
|
||||||
ctx.outputs.push({
|
|
||||||
let change_addr = dfvk.default_address().1;
|
|
||||||
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
|
||||||
let note = Note::from_parts(
|
|
||||||
change_addr,
|
|
||||||
NoteValue::from_raw((in_value - value).unwrap().into()),
|
|
||||||
rseed,
|
|
||||||
);
|
|
||||||
let encryptor = sapling_note_encryption::<_, Network>(
|
|
||||||
Some(dfvk.fvk().ovk),
|
|
||||||
note.clone(),
|
|
||||||
MemoBytes::empty(),
|
|
||||||
&mut rng,
|
|
||||||
);
|
|
||||||
let cmu = note.cmu().to_bytes().to_vec();
|
|
||||||
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
|
||||||
.0
|
|
||||||
.to_vec();
|
|
||||||
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
|
||||||
|
|
||||||
CompactSaplingOutput {
|
|
||||||
cmu,
|
|
||||||
ephemeral_key,
|
|
||||||
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut cb = CompactBlock {
|
|
||||||
hash: {
|
|
||||||
let mut hash = vec![0; 32];
|
|
||||||
rng.fill_bytes(&mut hash);
|
|
||||||
hash
|
|
||||||
},
|
|
||||||
height: height.into(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
|
||||||
cb.vtx.push(ctx);
|
|
||||||
cb.chain_metadata = Some(compact::ChainMetadata {
|
|
||||||
sapling_commitment_tree_size: initial_sapling_tree_size
|
|
||||||
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
cb
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert a fake CompactBlock into the cache DB.
|
|
||||||
pub(crate) fn insert_into_cache(db_cache: &BlockDb, cb: &CompactBlock) {
|
|
||||||
let cb_bytes = cb.encode_to_vec();
|
|
||||||
db_cache
|
|
||||||
.0
|
|
||||||
.prepare("INSERT INTO compactblocks (height, data) VALUES (?, ?)")
|
|
||||||
.unwrap()
|
|
||||||
.execute(params![u32::from(cb.height()), cb_bytes,])
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
pub(crate) fn store_in_fsblockdb<P: AsRef<Path>>(
|
use super::BlockDb;
|
||||||
fsblockdb_root: P,
|
|
||||||
cb: &CompactBlock,
|
|
||||||
) -> BlockMeta {
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
let meta = BlockMeta {
|
|
||||||
height: cb.height(),
|
|
||||||
block_hash: cb.hash(),
|
|
||||||
block_time: cb.time,
|
|
||||||
sapling_outputs_count: cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum(),
|
|
||||||
orchard_actions_count: cb.vtx.iter().map(|tx| tx.actions.len() as u32).sum(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let blocks_dir = fsblockdb_root.as_ref().join("blocks");
|
|
||||||
let block_path = meta.block_file_path(&blocks_dir);
|
|
||||||
|
|
||||||
File::create(block_path)
|
|
||||||
.unwrap()
|
|
||||||
.write_all(&cb.encode_to_vec())
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
meta
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub(crate) fn get_next_available_address() {
|
pub(crate) fn get_next_available_address() {
|
||||||
|
@ -1422,7 +1141,9 @@ mod tests {
|
||||||
use secrecy::Secret;
|
use secrecy::Secret;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
use crate::{chain::init::init_cache_database, wallet::init::init_wallet_db};
|
use crate::{
|
||||||
|
chain::init::init_cache_database, testing::network, wallet::init::init_wallet_db,
|
||||||
|
};
|
||||||
|
|
||||||
let cache_file = NamedTempFile::new().unwrap();
|
let cache_file = NamedTempFile::new().unwrap();
|
||||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||||
|
|
|
@ -0,0 +1,304 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
|
use std::{fs::File, path::Path};
|
||||||
|
|
||||||
|
use prost::Message;
|
||||||
|
use rand_core::{OsRng, RngCore};
|
||||||
|
use rusqlite::params;
|
||||||
|
|
||||||
|
use zcash_client_backend::{
|
||||||
|
keys::{sapling, UnifiedFullViewingKey},
|
||||||
|
proto::compact_formats::{
|
||||||
|
self as compact, CompactBlock, CompactSaplingOutput, CompactSaplingSpend, CompactTx,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use zcash_note_encryption::Domain;
|
||||||
|
use zcash_primitives::{
|
||||||
|
block::BlockHash,
|
||||||
|
consensus::{BlockHeight, Network, NetworkUpgrade, Parameters},
|
||||||
|
legacy::TransparentAddress,
|
||||||
|
memo::MemoBytes,
|
||||||
|
sapling::{
|
||||||
|
note_encryption::{sapling_note_encryption, SaplingDomain},
|
||||||
|
util::generate_random_rseed,
|
||||||
|
value::NoteValue,
|
||||||
|
Note, Nullifier, PaymentAddress,
|
||||||
|
},
|
||||||
|
transaction::components::Amount,
|
||||||
|
zip32::{sapling::DiversifiableFullViewingKey, DiversifierIndex},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
use zcash_primitives::{legacy, legacy::keys::IncomingViewingKey};
|
||||||
|
|
||||||
|
use crate::{wallet::init::init_accounts_table, AccountId, WalletDb};
|
||||||
|
|
||||||
|
use super::BlockDb;
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
|
use super::chain::BlockMeta;
|
||||||
|
|
||||||
|
#[cfg(feature = "mainnet")]
|
||||||
|
pub(crate) fn network() -> Network {
|
||||||
|
Network::MainNetwork
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "mainnet"))]
|
||||||
|
pub(crate) fn network() -> Network {
|
||||||
|
Network::TestNetwork
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mainnet")]
|
||||||
|
pub(crate) fn sapling_activation_height() -> BlockHeight {
|
||||||
|
Network::MainNetwork
|
||||||
|
.activation_height(NetworkUpgrade::Sapling)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "mainnet"))]
|
||||||
|
pub(crate) fn sapling_activation_height() -> BlockHeight {
|
||||||
|
Network::TestNetwork
|
||||||
|
.activation_height(NetworkUpgrade::Sapling)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn init_test_accounts_table(
|
||||||
|
db_data: &mut WalletDb<rusqlite::Connection, Network>,
|
||||||
|
) -> (DiversifiableFullViewingKey, Option<TransparentAddress>) {
|
||||||
|
let (ufvk, taddr) = init_test_accounts_table_ufvk(db_data);
|
||||||
|
(ufvk.sapling().unwrap().clone(), taddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn init_test_accounts_table_ufvk(
|
||||||
|
db_data: &mut WalletDb<rusqlite::Connection, Network>,
|
||||||
|
) -> (UnifiedFullViewingKey, Option<TransparentAddress>) {
|
||||||
|
let seed = [0u8; 32];
|
||||||
|
let account = AccountId::from(0);
|
||||||
|
let extsk = sapling::spending_key(&seed, network().coin_type(), account);
|
||||||
|
let dfvk = extsk.to_diversifiable_full_viewing_key();
|
||||||
|
|
||||||
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
let (tkey, taddr) = {
|
||||||
|
let tkey = legacy::keys::AccountPrivKey::from_seed(&network(), &seed, account)
|
||||||
|
.unwrap()
|
||||||
|
.to_account_pubkey();
|
||||||
|
let taddr = tkey.derive_external_ivk().unwrap().default_address().0;
|
||||||
|
(Some(tkey), Some(taddr))
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "transparent-inputs"))]
|
||||||
|
let taddr = None;
|
||||||
|
|
||||||
|
let ufvk = UnifiedFullViewingKey::new(
|
||||||
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
tkey,
|
||||||
|
Some(dfvk),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let ufvks = HashMap::from([(account, ufvk.clone())]);
|
||||||
|
init_accounts_table(db_data, &ufvks).unwrap();
|
||||||
|
|
||||||
|
(ufvk, taddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) enum AddressType {
|
||||||
|
DefaultExternal,
|
||||||
|
DiversifiedExternal(DiversifierIndex),
|
||||||
|
Internal,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a fake CompactBlock at the given height, containing a single output paying
|
||||||
|
/// an address. Returns the CompactBlock and the nullifier for the new note.
|
||||||
|
pub(crate) fn fake_compact_block(
|
||||||
|
height: BlockHeight,
|
||||||
|
prev_hash: BlockHash,
|
||||||
|
dfvk: &DiversifiableFullViewingKey,
|
||||||
|
req: AddressType,
|
||||||
|
value: Amount,
|
||||||
|
initial_sapling_tree_size: u32,
|
||||||
|
) -> (CompactBlock, Nullifier) {
|
||||||
|
let to = match req {
|
||||||
|
AddressType::DefaultExternal => dfvk.default_address().1,
|
||||||
|
AddressType::DiversifiedExternal(idx) => dfvk.find_address(idx).unwrap().1,
|
||||||
|
AddressType::Internal => dfvk.change_address().1,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create a fake Note for the account
|
||||||
|
let mut rng = OsRng;
|
||||||
|
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
||||||
|
let note = Note::from_parts(to, NoteValue::from_raw(value.into()), rseed);
|
||||||
|
let encryptor = sapling_note_encryption::<_, Network>(
|
||||||
|
Some(dfvk.fvk().ovk),
|
||||||
|
note.clone(),
|
||||||
|
MemoBytes::empty(),
|
||||||
|
&mut rng,
|
||||||
|
);
|
||||||
|
let cmu = note.cmu().to_bytes().to_vec();
|
||||||
|
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
||||||
|
.0
|
||||||
|
.to_vec();
|
||||||
|
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
||||||
|
|
||||||
|
// Create a fake CompactBlock containing the note
|
||||||
|
let cout = CompactSaplingOutput {
|
||||||
|
cmu,
|
||||||
|
ephemeral_key,
|
||||||
|
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
||||||
|
};
|
||||||
|
let mut ctx = CompactTx::default();
|
||||||
|
let mut txid = vec![0; 32];
|
||||||
|
rng.fill_bytes(&mut txid);
|
||||||
|
ctx.hash = txid;
|
||||||
|
ctx.outputs.push(cout);
|
||||||
|
let mut cb = CompactBlock {
|
||||||
|
hash: {
|
||||||
|
let mut hash = vec![0; 32];
|
||||||
|
rng.fill_bytes(&mut hash);
|
||||||
|
hash
|
||||||
|
},
|
||||||
|
height: height.into(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
||||||
|
cb.vtx.push(ctx);
|
||||||
|
cb.chain_metadata = Some(compact::ChainMetadata {
|
||||||
|
sapling_commitment_tree_size: initial_sapling_tree_size
|
||||||
|
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
(cb, note.nf(&dfvk.fvk().vk.nk, 0))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a fake CompactBlock at the given height, spending a single note from the
|
||||||
|
/// given address.
|
||||||
|
pub(crate) fn fake_compact_block_spending(
|
||||||
|
height: BlockHeight,
|
||||||
|
prev_hash: BlockHash,
|
||||||
|
(nf, in_value): (Nullifier, Amount),
|
||||||
|
dfvk: &DiversifiableFullViewingKey,
|
||||||
|
to: PaymentAddress,
|
||||||
|
value: Amount,
|
||||||
|
initial_sapling_tree_size: u32,
|
||||||
|
) -> CompactBlock {
|
||||||
|
let mut rng = OsRng;
|
||||||
|
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
||||||
|
|
||||||
|
// Create a fake CompactBlock containing the note
|
||||||
|
let cspend = CompactSaplingSpend { nf: nf.to_vec() };
|
||||||
|
let mut ctx = CompactTx::default();
|
||||||
|
let mut txid = vec![0; 32];
|
||||||
|
rng.fill_bytes(&mut txid);
|
||||||
|
ctx.hash = txid;
|
||||||
|
ctx.spends.push(cspend);
|
||||||
|
|
||||||
|
// Create a fake Note for the payment
|
||||||
|
ctx.outputs.push({
|
||||||
|
let note = Note::from_parts(to, NoteValue::from_raw(value.into()), rseed);
|
||||||
|
let encryptor = sapling_note_encryption::<_, Network>(
|
||||||
|
Some(dfvk.fvk().ovk),
|
||||||
|
note.clone(),
|
||||||
|
MemoBytes::empty(),
|
||||||
|
&mut rng,
|
||||||
|
);
|
||||||
|
let cmu = note.cmu().to_bytes().to_vec();
|
||||||
|
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
||||||
|
.0
|
||||||
|
.to_vec();
|
||||||
|
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
||||||
|
|
||||||
|
CompactSaplingOutput {
|
||||||
|
cmu,
|
||||||
|
ephemeral_key,
|
||||||
|
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a fake Note for the change
|
||||||
|
ctx.outputs.push({
|
||||||
|
let change_addr = dfvk.default_address().1;
|
||||||
|
let rseed = generate_random_rseed(&network(), height, &mut rng);
|
||||||
|
let note = Note::from_parts(
|
||||||
|
change_addr,
|
||||||
|
NoteValue::from_raw((in_value - value).unwrap().into()),
|
||||||
|
rseed,
|
||||||
|
);
|
||||||
|
let encryptor = sapling_note_encryption::<_, Network>(
|
||||||
|
Some(dfvk.fvk().ovk),
|
||||||
|
note.clone(),
|
||||||
|
MemoBytes::empty(),
|
||||||
|
&mut rng,
|
||||||
|
);
|
||||||
|
let cmu = note.cmu().to_bytes().to_vec();
|
||||||
|
let ephemeral_key = SaplingDomain::<Network>::epk_bytes(encryptor.epk())
|
||||||
|
.0
|
||||||
|
.to_vec();
|
||||||
|
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
||||||
|
|
||||||
|
CompactSaplingOutput {
|
||||||
|
cmu,
|
||||||
|
ephemeral_key,
|
||||||
|
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let mut cb = CompactBlock {
|
||||||
|
hash: {
|
||||||
|
let mut hash = vec![0; 32];
|
||||||
|
rng.fill_bytes(&mut hash);
|
||||||
|
hash
|
||||||
|
},
|
||||||
|
height: height.into(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
||||||
|
cb.vtx.push(ctx);
|
||||||
|
cb.chain_metadata = Some(compact::ChainMetadata {
|
||||||
|
sapling_commitment_tree_size: initial_sapling_tree_size
|
||||||
|
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
cb
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Insert a fake CompactBlock into the cache DB.
|
||||||
|
pub(crate) fn insert_into_cache(db_cache: &BlockDb, cb: &CompactBlock) {
|
||||||
|
let cb_bytes = cb.encode_to_vec();
|
||||||
|
db_cache
|
||||||
|
.0
|
||||||
|
.prepare("INSERT INTO compactblocks (height, data) VALUES (?, ?)")
|
||||||
|
.unwrap()
|
||||||
|
.execute(params![u32::from(cb.height()), cb_bytes,])
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable")]
|
||||||
|
pub(crate) fn store_in_fsblockdb<P: AsRef<Path>>(
|
||||||
|
fsblockdb_root: P,
|
||||||
|
cb: &CompactBlock,
|
||||||
|
) -> BlockMeta {
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
let meta = BlockMeta {
|
||||||
|
height: cb.height(),
|
||||||
|
block_hash: cb.hash(),
|
||||||
|
block_time: cb.time,
|
||||||
|
sapling_outputs_count: cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum(),
|
||||||
|
orchard_actions_count: cb.vtx.iter().map(|tx| tx.actions.len() as u32).sum(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let blocks_dir = fsblockdb_root.as_ref().join("blocks");
|
||||||
|
let block_path = meta.block_file_path(&blocks_dir);
|
||||||
|
|
||||||
|
File::create(block_path)
|
||||||
|
.unwrap()
|
||||||
|
.write_all(&cb.encode_to_vec())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
meta
|
||||||
|
}
|
|
@ -1579,7 +1579,7 @@ mod tests {
|
||||||
use zcash_client_backend::data_api::WalletRead;
|
use zcash_client_backend::data_api::WalletRead;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests,
|
testing,
|
||||||
wallet::{get_current_address, init::init_wallet_db},
|
wallet::{get_current_address, init::init_wallet_db},
|
||||||
AccountId, WalletDb,
|
AccountId, WalletDb,
|
||||||
};
|
};
|
||||||
|
@ -1600,11 +1600,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_database_has_no_balance() {
|
fn empty_database_has_no_balance() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
tests::init_test_accounts_table(&mut db_data);
|
testing::init_test_accounts_table(&mut db_data);
|
||||||
|
|
||||||
// The account should be empty
|
// The account should be empty
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1635,7 +1635,7 @@ mod tests {
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
fn put_received_transparent_utxo() {
|
fn put_received_transparent_utxo() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
|
|
@ -988,11 +988,11 @@ mod tests {
|
||||||
use zcash_primitives::consensus::BlockHeight;
|
use zcash_primitives::consensus::BlockHeight;
|
||||||
|
|
||||||
use super::SqliteShardStore;
|
use super::SqliteShardStore;
|
||||||
use crate::{tests, wallet::init::init_wallet_db, WalletDb, SAPLING_TABLES_PREFIX};
|
use crate::{testing, wallet::init::init_wallet_db, WalletDb, SAPLING_TABLES_PREFIX};
|
||||||
|
|
||||||
fn new_tree(m: usize) -> ShardTree<SqliteShardStore<rusqlite::Connection, String, 3>, 4, 3> {
|
fn new_tree(m: usize) -> ShardTree<SqliteShardStore<rusqlite::Connection, String, 3>, 4, 3> {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
data_file.keep().unwrap();
|
data_file.keep().unwrap();
|
||||||
|
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
@ -1040,7 +1040,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn put_shard_roots() {
|
fn put_shard_roots() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
data_file.keep().unwrap();
|
data_file.keep().unwrap();
|
||||||
|
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
|
@ -393,7 +393,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::SqliteClientError,
|
error::SqliteClientError,
|
||||||
tests::{self, network},
|
testing::{self, network},
|
||||||
wallet::scanning::priority_code,
|
wallet::scanning::priority_code,
|
||||||
AccountId, WalletDb,
|
AccountId, WalletDb,
|
||||||
};
|
};
|
||||||
|
@ -415,7 +415,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_schema() {
|
fn verify_schema() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -609,7 +609,7 @@ mod tests {
|
||||||
AND (scan_queue.block_range_end - 1) >= shard.subtree_end_height
|
AND (scan_queue.block_range_end - 1) >= shard.subtree_end_height
|
||||||
)
|
)
|
||||||
WHERE scan_queue.priority > {}",
|
WHERE scan_queue.priority > {}",
|
||||||
u32::from(tests::network().activation_height(NetworkUpgrade::Sapling).unwrap()),
|
u32::from(testing::network().activation_height(NetworkUpgrade::Sapling).unwrap()),
|
||||||
priority_code(&ScanPriority::Scanned),
|
priority_code(&ScanPriority::Scanned),
|
||||||
),
|
),
|
||||||
// v_transactions
|
// v_transactions
|
||||||
|
@ -852,11 +852,11 @@ mod tests {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let address = encode_payment_address(
|
let address = encode_payment_address(
|
||||||
tests::network().hrp_sapling_payment_address(),
|
testing::network().hrp_sapling_payment_address(),
|
||||||
&extfvk.default_address().1,
|
&extfvk.default_address().1,
|
||||||
);
|
);
|
||||||
let extfvk = encode_extended_full_viewing_key(
|
let extfvk = encode_extended_full_viewing_key(
|
||||||
tests::network().hrp_sapling_extended_full_viewing_key(),
|
testing::network().hrp_sapling_extended_full_viewing_key(),
|
||||||
extfvk,
|
extfvk,
|
||||||
);
|
);
|
||||||
wdb.conn.execute(
|
wdb.conn.execute(
|
||||||
|
@ -874,10 +874,10 @@ mod tests {
|
||||||
|
|
||||||
let seed = [0xab; 32];
|
let seed = [0xab; 32];
|
||||||
let account = AccountId::from(0);
|
let account = AccountId::from(0);
|
||||||
let secret_key = sapling::spending_key(&seed, tests::network().coin_type(), account);
|
let secret_key = sapling::spending_key(&seed, testing::network().coin_type(), account);
|
||||||
let extfvk = secret_key.to_extended_full_viewing_key();
|
let extfvk = secret_key.to_extended_full_viewing_key();
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_0_3_0(&mut db_data, &extfvk, account).unwrap();
|
init_0_3_0(&mut db_data, &extfvk, account).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(seed.to_vec()))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(seed.to_vec()))).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -984,11 +984,11 @@ mod tests {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let address = encode_payment_address(
|
let address = encode_payment_address(
|
||||||
tests::network().hrp_sapling_payment_address(),
|
testing::network().hrp_sapling_payment_address(),
|
||||||
&extfvk.default_address().1,
|
&extfvk.default_address().1,
|
||||||
);
|
);
|
||||||
let extfvk = encode_extended_full_viewing_key(
|
let extfvk = encode_extended_full_viewing_key(
|
||||||
tests::network().hrp_sapling_extended_full_viewing_key(),
|
testing::network().hrp_sapling_extended_full_viewing_key(),
|
||||||
extfvk,
|
extfvk,
|
||||||
);
|
);
|
||||||
wdb.conn.execute(
|
wdb.conn.execute(
|
||||||
|
@ -1040,10 +1040,10 @@ mod tests {
|
||||||
|
|
||||||
let seed = [0xab; 32];
|
let seed = [0xab; 32];
|
||||||
let account = AccountId::from(0);
|
let account = AccountId::from(0);
|
||||||
let secret_key = sapling::spending_key(&seed, tests::network().coin_type(), account);
|
let secret_key = sapling::spending_key(&seed, testing::network().coin_type(), account);
|
||||||
let extfvk = secret_key.to_extended_full_viewing_key();
|
let extfvk = secret_key.to_extended_full_viewing_key();
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_autoshielding(&mut db_data, &extfvk, account).unwrap();
|
init_autoshielding(&mut db_data, &extfvk, account).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(seed.to_vec()))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(seed.to_vec()))).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -1150,9 +1150,9 @@ mod tests {
|
||||||
[],
|
[],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let ufvk_str = ufvk.encode(&tests::network());
|
let ufvk_str = ufvk.encode(&testing::network());
|
||||||
let address_str =
|
let address_str =
|
||||||
RecipientAddress::Unified(ufvk.default_address().0).encode(&tests::network());
|
RecipientAddress::Unified(ufvk.default_address().0).encode(&testing::network());
|
||||||
wdb.conn.execute(
|
wdb.conn.execute(
|
||||||
"INSERT INTO accounts (account, ufvk, address, transparent_address)
|
"INSERT INTO accounts (account, ufvk, address, transparent_address)
|
||||||
VALUES (?, ?, ?, '')",
|
VALUES (?, ?, ?, '')",
|
||||||
|
@ -1168,7 +1168,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
let taddr =
|
let taddr =
|
||||||
RecipientAddress::Transparent(*ufvk.default_address().0.transparent().unwrap())
|
RecipientAddress::Transparent(*ufvk.default_address().0.transparent().unwrap())
|
||||||
.encode(&tests::network());
|
.encode(&testing::network());
|
||||||
wdb.conn.execute(
|
wdb.conn.execute(
|
||||||
"INSERT INTO blocks (height, hash, time, sapling_tree) VALUES (0, 0, 0, x'000000')",
|
"INSERT INTO blocks (height, hash, time, sapling_tree) VALUES (0, 0, 0, x'000000')",
|
||||||
[],
|
[],
|
||||||
|
@ -1188,9 +1188,10 @@ mod tests {
|
||||||
|
|
||||||
let seed = [0xab; 32];
|
let seed = [0xab; 32];
|
||||||
let account = AccountId::from(0);
|
let account = AccountId::from(0);
|
||||||
let secret_key = UnifiedSpendingKey::from_seed(&tests::network(), &seed, account).unwrap();
|
let secret_key =
|
||||||
|
UnifiedSpendingKey::from_seed(&testing::network(), &seed, account).unwrap();
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_main(
|
init_main(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&secret_key.to_unified_full_viewing_key(),
|
&secret_key.to_unified_full_viewing_key(),
|
||||||
|
@ -1203,7 +1204,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn init_accounts_table_only_works_once() {
|
fn init_accounts_table_only_works_once() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// We can call the function as many times as we want with no data
|
// We can call the function as many times as we want with no data
|
||||||
|
@ -1272,7 +1273,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn init_blocks_table_only_works_once() {
|
fn init_blocks_table_only_works_once() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// First call with data should initialise the blocks table
|
// First call with data should initialise the blocks table
|
||||||
|
@ -1299,14 +1300,14 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn init_accounts_table_stores_correct_address() {
|
fn init_accounts_table_stores_correct_address() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
let seed = [0u8; 32];
|
let seed = [0u8; 32];
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
let account_id = AccountId::from(0);
|
let account_id = AccountId::from(0);
|
||||||
let usk = UnifiedSpendingKey::from_seed(&tests::network(), &seed, account_id).unwrap();
|
let usk = UnifiedSpendingKey::from_seed(&testing::network(), &seed, account_id).unwrap();
|
||||||
let ufvk = usk.to_unified_full_viewing_key();
|
let ufvk = usk.to_unified_full_viewing_key();
|
||||||
let expected_address = ufvk.sapling().unwrap().default_address().1;
|
let expected_address = ufvk.sapling().unwrap().default_address().1;
|
||||||
let ufvks = HashMap::from([(account_id, ufvk)]);
|
let ufvks = HashMap::from([(account_id, ufvk)]);
|
||||||
|
|
|
@ -286,7 +286,7 @@ mod tests {
|
||||||
use zcash_primitives::zip32::AccountId;
|
use zcash_primitives::zip32::AccountId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests,
|
testing,
|
||||||
wallet::init::{init_wallet_db_internal, migrations::addresses_table},
|
wallet::init::{init_wallet_db_internal, migrations::addresses_table},
|
||||||
WalletDb,
|
WalletDb,
|
||||||
};
|
};
|
||||||
|
@ -311,10 +311,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_views() {
|
fn transaction_views() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db_internal(&mut db_data, None, &[addresses_table::MIGRATION_ID]).unwrap();
|
init_wallet_db_internal(&mut db_data, None, &[addresses_table::MIGRATION_ID]).unwrap();
|
||||||
let usk =
|
let usk =
|
||||||
UnifiedSpendingKey::from_seed(&tests::network(), &[0u8; 32][..], AccountId::from(0))
|
UnifiedSpendingKey::from_seed(&testing::network(), &[0u8; 32][..], AccountId::from(0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ufvk = usk.to_unified_full_viewing_key();
|
let ufvk = usk.to_unified_full_viewing_key();
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ mod tests {
|
||||||
.conn
|
.conn
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
||||||
params![ufvk.encode(&tests::network())],
|
params![ufvk.encode(&testing::network())],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ mod tests {
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
fn migrate_from_wm2() {
|
fn migrate_from_wm2() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db_internal(
|
init_wallet_db_internal(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
None,
|
None,
|
||||||
|
@ -440,7 +440,7 @@ mod tests {
|
||||||
tx.write(&mut tx_bytes).unwrap();
|
tx.write(&mut tx_bytes).unwrap();
|
||||||
|
|
||||||
let usk =
|
let usk =
|
||||||
UnifiedSpendingKey::from_seed(&tests::network(), &[0u8; 32][..], AccountId::from(0))
|
UnifiedSpendingKey::from_seed(&testing::network(), &[0u8; 32][..], AccountId::from(0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ufvk = usk.to_unified_full_viewing_key();
|
let ufvk = usk.to_unified_full_viewing_key();
|
||||||
let (ua, _) = ufvk.default_address();
|
let (ua, _) = ufvk.default_address();
|
||||||
|
@ -451,11 +451,11 @@ mod tests {
|
||||||
.ok()
|
.ok()
|
||||||
.map(|k| k.derive_address(0).unwrap())
|
.map(|k| k.derive_address(0).unwrap())
|
||||||
})
|
})
|
||||||
.map(|a| a.encode(&tests::network()));
|
.map(|a| a.encode(&testing::network()));
|
||||||
|
|
||||||
db_data.conn.execute(
|
db_data.conn.execute(
|
||||||
"INSERT INTO accounts (account, ufvk, address, transparent_address) VALUES (0, ?, ?, ?)",
|
"INSERT INTO accounts (account, ufvk, address, transparent_address) VALUES (0, ?, ?, ?)",
|
||||||
params![ufvk.encode(&tests::network()), ua.encode(&tests::network()), &taddr]
|
params![ufvk.encode(&testing::network()), ua.encode(&testing::network()), &taddr]
|
||||||
).unwrap();
|
).unwrap();
|
||||||
db_data
|
db_data
|
||||||
.conn
|
.conn
|
||||||
|
|
|
@ -236,7 +236,7 @@ mod tests {
|
||||||
use zcash_primitives::zip32::AccountId;
|
use zcash_primitives::zip32::AccountId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests,
|
testing,
|
||||||
wallet::init::{init_wallet_db_internal, migrations::v_transactions_net},
|
wallet::init::{init_wallet_db_internal, migrations::v_transactions_net},
|
||||||
WalletDb,
|
WalletDb,
|
||||||
};
|
};
|
||||||
|
@ -244,19 +244,19 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn received_notes_nullable_migration() {
|
fn received_notes_nullable_migration() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db_internal(&mut db_data, None, &[v_transactions_net::MIGRATION_ID]).unwrap();
|
init_wallet_db_internal(&mut db_data, None, &[v_transactions_net::MIGRATION_ID]).unwrap();
|
||||||
|
|
||||||
// Create an account in the wallet
|
// Create an account in the wallet
|
||||||
let usk0 =
|
let usk0 =
|
||||||
UnifiedSpendingKey::from_seed(&tests::network(), &[0u8; 32][..], AccountId::from(0))
|
UnifiedSpendingKey::from_seed(&testing::network(), &[0u8; 32][..], AccountId::from(0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ufvk0 = usk0.to_unified_full_viewing_key();
|
let ufvk0 = usk0.to_unified_full_viewing_key();
|
||||||
db_data
|
db_data
|
||||||
.conn
|
.conn
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
||||||
params![ufvk0.encode(&tests::network())],
|
params![ufvk0.encode(&testing::network())],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ mod tests {
|
||||||
use zcash_primitives::zip32::AccountId;
|
use zcash_primitives::zip32::AccountId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
tests,
|
testing,
|
||||||
wallet::init::{init_wallet_db_internal, migrations::add_transaction_views},
|
wallet::init::{init_wallet_db_internal, migrations::add_transaction_views},
|
||||||
WalletDb,
|
WalletDb,
|
||||||
};
|
};
|
||||||
|
@ -223,32 +223,32 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn v_transactions_net() {
|
fn v_transactions_net() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db_internal(&mut db_data, None, &[add_transaction_views::MIGRATION_ID])
|
init_wallet_db_internal(&mut db_data, None, &[add_transaction_views::MIGRATION_ID])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Create two accounts in the wallet.
|
// Create two accounts in the wallet.
|
||||||
let usk0 =
|
let usk0 =
|
||||||
UnifiedSpendingKey::from_seed(&tests::network(), &[0u8; 32][..], AccountId::from(0))
|
UnifiedSpendingKey::from_seed(&testing::network(), &[0u8; 32][..], AccountId::from(0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ufvk0 = usk0.to_unified_full_viewing_key();
|
let ufvk0 = usk0.to_unified_full_viewing_key();
|
||||||
db_data
|
db_data
|
||||||
.conn
|
.conn
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
"INSERT INTO accounts (account, ufvk) VALUES (0, ?)",
|
||||||
params![ufvk0.encode(&tests::network())],
|
params![ufvk0.encode(&testing::network())],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let usk1 =
|
let usk1 =
|
||||||
UnifiedSpendingKey::from_seed(&tests::network(), &[1u8; 32][..], AccountId::from(1))
|
UnifiedSpendingKey::from_seed(&testing::network(), &[1u8; 32][..], AccountId::from(1))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let ufvk1 = usk1.to_unified_full_viewing_key();
|
let ufvk1 = usk1.to_unified_full_viewing_key();
|
||||||
db_data
|
db_data
|
||||||
.conn
|
.conn
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO accounts (account, ufvk) VALUES (1, ?)",
|
"INSERT INTO accounts (account, ufvk) VALUES (1, ?)",
|
||||||
params![ufvk1.encode(&tests::network())],
|
params![ufvk1.encode(&testing::network())],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -448,7 +448,7 @@ pub(crate) mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
chain::init::init_cache_database,
|
chain::init::init_cache_database,
|
||||||
error::SqliteClientError,
|
error::SqliteClientError,
|
||||||
tests::{
|
testing::{
|
||||||
self, fake_compact_block, insert_into_cache, network, sapling_activation_height,
|
self, fake_compact_block, insert_into_cache, network, sapling_activation_height,
|
||||||
AddressType,
|
AddressType,
|
||||||
},
|
},
|
||||||
|
@ -480,7 +480,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -500,7 +500,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -540,7 +540,7 @@ pub(crate) mod tests {
|
||||||
&GreedyInputSelector::new(change_strategy, DustOutputPolicy::default());
|
&GreedyInputSelector::new(change_strategy, DustOutputPolicy::default());
|
||||||
let proposal_result = propose_transfer::<_, _, _, Infallible>(
|
let proposal_result = propose_transfer::<_, _, _, Infallible>(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
account,
|
account,
|
||||||
input_selector,
|
input_selector,
|
||||||
request,
|
request,
|
||||||
|
@ -551,7 +551,7 @@ pub(crate) mod tests {
|
||||||
let change_memo = "Test change memo".parse::<Memo>().unwrap();
|
let change_memo = "Test change memo".parse::<Memo>().unwrap();
|
||||||
let create_proposed_result = create_proposed_transaction::<_, _, Infallible, _>(
|
let create_proposed_result = create_proposed_transaction::<_, _, Infallible, _>(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
OvkPolicy::Sender,
|
OvkPolicy::Sender,
|
||||||
|
@ -571,7 +571,7 @@ pub(crate) mod tests {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect();
|
.collect();
|
||||||
let decrypted_outputs = decrypt_transaction(
|
let decrypted_outputs = decrypt_transaction(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
&tx,
|
&tx,
|
||||||
&ufvks,
|
&ufvks,
|
||||||
|
@ -650,7 +650,7 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn create_to_address_fails_on_incorrect_usk() {
|
fn create_to_address_fails_on_incorrect_usk() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -667,7 +667,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk1,
|
&usk1,
|
||||||
&to,
|
&to,
|
||||||
|
@ -683,7 +683,7 @@ pub(crate) mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn create_to_address_fails_with_no_blocks() {
|
fn create_to_address_fails_with_no_blocks() {
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -702,7 +702,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -722,7 +722,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -742,7 +742,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -776,7 +776,7 @@ pub(crate) mod tests {
|
||||||
.0;
|
.0;
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -804,7 +804,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -836,7 +836,7 @@ pub(crate) mod tests {
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
}
|
}
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 2,
|
sapling_activation_height() + 2,
|
||||||
|
@ -848,7 +848,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -877,7 +877,7 @@ pub(crate) mod tests {
|
||||||
.0;
|
.0;
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 10,
|
sapling_activation_height() + 10,
|
||||||
|
@ -889,7 +889,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -909,7 +909,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -929,7 +929,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -947,7 +947,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -963,7 +963,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -994,7 +994,7 @@ pub(crate) mod tests {
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
}
|
}
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 1,
|
sapling_activation_height() + 1,
|
||||||
|
@ -1006,7 +1006,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -1034,7 +1034,7 @@ pub(crate) mod tests {
|
||||||
.0;
|
.0;
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height() + 42,
|
sapling_activation_height() + 42,
|
||||||
|
@ -1045,7 +1045,7 @@ pub(crate) mod tests {
|
||||||
// Second spend should now succeed
|
// Second spend should now succeed
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -1059,7 +1059,7 @@ pub(crate) mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ovk_policy_prevents_recovery_from_chain() {
|
fn ovk_policy_prevents_recovery_from_chain() {
|
||||||
let network = tests::network();
|
let network = testing::network();
|
||||||
let cache_file = NamedTempFile::new().unwrap();
|
let cache_file = NamedTempFile::new().unwrap();
|
||||||
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
@ -1085,7 +1085,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -1116,7 +1116,7 @@ pub(crate) mod tests {
|
||||||
> {
|
> {
|
||||||
let txid = create_spend_to_address(
|
let txid = create_spend_to_address(
|
||||||
db_data,
|
db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -1200,7 +1200,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -1220,7 +1220,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -1246,7 +1246,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -1266,7 +1266,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -1286,7 +1286,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -1312,7 +1312,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
create_spend_to_address(
|
create_spend_to_address(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&usk,
|
&usk,
|
||||||
&to,
|
&to,
|
||||||
|
@ -1332,7 +1332,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -1366,7 +1366,7 @@ pub(crate) mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -1408,7 +1408,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
spend(
|
spend(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&input_selector,
|
&input_selector,
|
||||||
&usk,
|
&usk,
|
||||||
|
@ -1436,7 +1436,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
spend(
|
spend(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&input_selector,
|
&input_selector,
|
||||||
&usk,
|
&usk,
|
||||||
|
@ -1456,7 +1456,7 @@ pub(crate) mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, None).unwrap();
|
init_wallet_db(&mut db_data, None).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet
|
// Add an account to the wallet
|
||||||
|
@ -1495,7 +1495,7 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
insert_into_cache(&db_cache, &cb);
|
insert_into_cache(&db_cache, &cb);
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
sapling_activation_height(),
|
sapling_activation_height(),
|
||||||
|
@ -1506,7 +1506,7 @@ pub(crate) mod tests {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
shield_transparent_funds(
|
shield_transparent_funds(
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
test_prover(),
|
test_prover(),
|
||||||
&input_selector,
|
&input_selector,
|
||||||
NonNegativeAmount::from_u64(10000).unwrap(),
|
NonNegativeAmount::from_u64(10000).unwrap(),
|
||||||
|
|
|
@ -755,7 +755,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chain::init::init_cache_database,
|
chain::init::init_cache_database,
|
||||||
tests::{
|
testing::{
|
||||||
self, fake_compact_block, init_test_accounts_table, insert_into_cache,
|
self, fake_compact_block, init_test_accounts_table, insert_into_cache,
|
||||||
sapling_activation_height, AddressType,
|
sapling_activation_height, AddressType,
|
||||||
},
|
},
|
||||||
|
@ -1098,7 +1098,7 @@ mod tests {
|
||||||
init_cache_database(&db_cache).unwrap();
|
init_cache_database(&db_cache).unwrap();
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
// Add an account to the wallet.
|
// Add an account to the wallet.
|
||||||
|
@ -1159,7 +1159,7 @@ mod tests {
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
scan_cached_blocks(
|
scan_cached_blocks(
|
||||||
&tests::network(),
|
&testing::network(),
|
||||||
&db_cache,
|
&db_cache,
|
||||||
&mut db_data,
|
&mut db_data,
|
||||||
initial_height,
|
initial_height,
|
||||||
|
@ -1226,7 +1226,7 @@ mod tests {
|
||||||
use ScanPriority::*;
|
use ScanPriority::*;
|
||||||
|
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), testing::network()).unwrap();
|
||||||
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
init_wallet_db(&mut db_data, Some(Secret::new(vec![]))).unwrap();
|
||||||
|
|
||||||
let sap_active = db_data
|
let sap_active = db_data
|
||||||
|
|
Loading…
Reference in New Issue