Improve naming for wallet/block database connections.

This commit is contained in:
Kris Nuttycombe 2020-10-21 13:08:09 -06:00
parent ee0e059eb3
commit 1fd74d0a71
8 changed files with 95 additions and 95 deletions

View File

@ -113,14 +113,14 @@ where
/// data_api::chain::scan_cached_blocks,
/// };
/// use zcash_client_sqlite::{
/// CacheConnection,
/// DataConnection,
/// BlockDB,
/// WalletDB,
/// };
///
/// let cache_file = NamedTempFile::new().unwrap();
/// let cache = CacheConnection::for_path(cache_file).unwrap();
/// let cache = BlockDB::for_path(cache_file).unwrap();
/// let data_file = NamedTempFile::new().unwrap();
/// let data = DataConnection::for_path(data_file).unwrap();
/// let data = WalletDB::for_path(data_file).unwrap();
/// scan_cached_blocks(&Network::TestNetwork, &cache, &data, None);
/// ```
///

View File

@ -113,7 +113,7 @@ where
/// wallet::OvkPolicy,
/// };
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// };
///
/// let tx_prover = match LocalTxProver::with_default_location() {
@ -128,7 +128,7 @@ where
/// let to = extsk.default_address().unwrap().1.into();
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// match create_spend_to_address(
/// &db,
/// &Network::TestNetwork,

View File

@ -20,16 +20,16 @@
//! };
//!
//! use zcash_client_sqlite::{
//! CacheConnection,
//! DataConnection,
//! BlockDB,
//! WalletDB,
//! wallet::{rewind_to_height},
//! };
//!
//! let network = Network::TestNetwork;
//! let cache_file = NamedTempFile::new().unwrap();
//! let db_cache = CacheConnection::for_path(cache_file).unwrap();
//! let db_cache = BlockDB::for_path(cache_file).unwrap();
//! let data_file = NamedTempFile::new().unwrap();
//! let db_data = DataConnection::for_path(data_file).unwrap();
//! let db_data = WalletDB::for_path(data_file).unwrap();
//!
//! // 1) Download new CompactBlocks into db_cache.
//!
@ -81,7 +81,7 @@ use zcash_primitives::consensus::BlockHeight;
use zcash_client_backend::{data_api::error::Error, proto::compact_formats::CompactBlock};
use crate::{error::SqliteClientError, CacheConnection};
use crate::{error::SqliteClientError, BlockDB};
pub mod init;
@ -91,7 +91,7 @@ struct CompactBlockRow {
}
pub fn with_blocks<F>(
cache: &CacheConnection,
cache: &BlockDB,
from_height: BlockHeight,
limit: Option<u32>,
mut with_row: F,
@ -163,17 +163,17 @@ mod tests {
init::{init_accounts_table, init_data_database},
rewind_to_height,
},
AccountId, CacheConnection, DataConnection, NoteId,
AccountId, BlockDB, WalletDB, NoteId,
};
#[test]
fn valid_chain_states() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -249,11 +249,11 @@ mod tests {
#[test]
fn invalid_chain_cache_disconnected() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -322,11 +322,11 @@ mod tests {
#[test]
fn invalid_chain_cache_reorg() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -395,11 +395,11 @@ mod tests {
#[test]
fn data_db_rewinding() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -453,11 +453,11 @@ mod tests {
#[test]
fn scan_cached_blocks_requires_sequential_blocks() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -517,11 +517,11 @@ mod tests {
#[test]
fn scan_cached_blocks_finds_received_notes() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -564,11 +564,11 @@ mod tests {
#[test]
fn scan_cached_blocks_finds_change_notes() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet

View File

@ -2,7 +2,7 @@
use rusqlite::NO_PARAMS;
use crate::CacheConnection;
use crate::BlockDB;
/// Sets up the internal structure of the cache database.
///
@ -11,15 +11,15 @@ use crate::CacheConnection;
/// ```
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// CacheConnection,
/// BlockDB,
/// chain::init::init_cache_database,
/// };
///
/// let cache_file = NamedTempFile::new().unwrap();
/// let db = CacheConnection::for_path(cache_file.path()).unwrap();
/// let db = BlockDB::for_path(cache_file.path()).unwrap();
/// init_cache_database(&db).unwrap();
/// ```
pub fn init_cache_database(db_cache: &CacheConnection) -> Result<(), rusqlite::Error> {
pub fn init_cache_database(db_cache: &BlockDB) -> Result<(), rusqlite::Error> {
db_cache.0.execute(
"CREATE TABLE IF NOT EXISTS compactblocks (
height INTEGER PRIMARY KEY,

View File

@ -66,15 +66,15 @@ impl fmt::Display for NoteId {
}
}
pub struct DataConnection(Connection);
pub struct WalletDB(Connection);
impl DataConnection {
impl WalletDB {
pub fn for_path<P: AsRef<Path>>(path: P) -> Result<Self, rusqlite::Error> {
Connection::open(path).map(DataConnection)
Connection::open(path).map(WalletDB)
}
}
impl<'a> WalletRead for &'a DataConnection {
impl<'a> WalletRead for &'a WalletDB {
type Error = SqliteClientError;
type NoteRef = NoteId;
type TxRef = i64;
@ -242,7 +242,7 @@ impl<'a> WalletRead for &'a DataConnection {
}
pub struct DataConnStmtCache<'a> {
conn: &'a DataConnection,
conn: &'a WalletDB,
stmt_insert_block: Statement<'a>,
stmt_insert_tx_meta: Statement<'a>,
@ -536,15 +536,15 @@ impl<'a> WalletWrite for DataConnStmtCache<'a> {
}
}
pub struct CacheConnection(Connection);
pub struct BlockDB(Connection);
impl CacheConnection {
impl BlockDB {
pub fn for_path<P: AsRef<Path>>(path: P) -> Result<Self, rusqlite::Error> {
Connection::open(path).map(CacheConnection)
Connection::open(path).map(BlockDB)
}
}
impl BlockSource for CacheConnection {
impl BlockSource for BlockDB {
type Error = SqliteClientError;
fn init_cache(&self) -> Result<(), Self::Error> {
@ -594,7 +594,7 @@ mod tests {
zip32::ExtendedFullViewingKey,
};
use super::CacheConnection;
use super::BlockDB;
#[cfg(feature = "mainnet")]
pub(crate) fn network() -> Network {
@ -755,7 +755,7 @@ mod tests {
}
/// Insert a fake CompactBlock into the cache DB.
pub(crate) fn insert_into_cache(db_cache: &CacheConnection, cb: &CompactBlock) {
pub(crate) fn insert_into_cache(db_cache: &BlockDB, cb: &CompactBlock) {
let cb_bytes = cb.write_to_bytes().unwrap();
db_cache
.0

View File

@ -20,7 +20,7 @@ use zcash_client_backend::{
},
};
use crate::{error::SqliteClientError, AccountId, DataConnection, NoteId};
use crate::{error::SqliteClientError, AccountId, WalletDB, NoteId};
pub mod init;
pub mod transact;
@ -36,16 +36,16 @@ pub mod transact;
/// };
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::get_address,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// let addr = get_address(&db, &Network::TestNetwork, AccountId(0));
/// ```
pub fn get_address<P: consensus::Parameters>(
data: &DataConnection,
data: &WalletDB,
params: &P,
account: AccountId,
) -> Result<Option<PaymentAddress>, SqliteClientError> {
@ -61,7 +61,7 @@ pub fn get_address<P: consensus::Parameters>(
}
pub fn get_extended_full_viewing_keys<P: consensus::Parameters>(
data: &DataConnection,
data: &WalletDB,
params: &P,
) -> Result<Vec<ExtendedFullViewingKey>, SqliteClientError> {
// Fetch the ExtendedFullViewingKeys we are tracking
@ -87,7 +87,7 @@ pub fn get_extended_full_viewing_keys<P: consensus::Parameters>(
}
pub fn is_valid_account_extfvk<P: consensus::Parameters>(
data: &DataConnection,
data: &WalletDB,
params: &P,
account: AccountId,
extfvk: &ExtendedFullViewingKey,
@ -119,15 +119,15 @@ pub fn is_valid_account_extfvk<P: consensus::Parameters>(
/// use tempfile::NamedTempFile;
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::get_balance,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// let addr = get_balance(&db, AccountId(0));
/// ```
pub fn get_balance(data: &DataConnection, account: AccountId) -> Result<Amount, SqliteClientError> {
pub fn get_balance(data: &WalletDB, account: AccountId) -> Result<Amount, SqliteClientError> {
let balance = data.0.query_row(
"SELECT SUM(value) FROM received_notes
INNER JOIN transactions ON transactions.id_tx = received_notes.tx
@ -154,16 +154,16 @@ pub fn get_balance(data: &DataConnection, account: AccountId) -> Result<Amount,
/// use zcash_primitives::consensus::{BlockHeight};
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::get_verified_balance,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// let addr = get_verified_balance(&db, AccountId(0), BlockHeight::from_u32(0));
/// ```
pub fn get_verified_balance(
data: &DataConnection,
data: &WalletDB,
account: AccountId,
anchor_height: BlockHeight,
) -> Result<Amount, SqliteClientError> {
@ -194,16 +194,16 @@ pub fn get_verified_balance(
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// NoteId,
/// DataConnection,
/// WalletDB,
/// wallet::get_received_memo_as_utf8,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// let memo = get_received_memo_as_utf8(&db, NoteId(27));
/// ```
pub fn get_received_memo_as_utf8(
data: &DataConnection,
data: &WalletDB,
id_note: NoteId,
) -> Result<Option<String>, SqliteClientError> {
let memo: Vec<_> = data.0.query_row(
@ -234,16 +234,16 @@ pub fn get_received_memo_as_utf8(
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// NoteId,
/// DataConnection,
/// WalletDB,
/// wallet::get_sent_memo_as_utf8,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let db = WalletDB::for_path(data_file).unwrap();
/// let memo = get_sent_memo_as_utf8(&db, NoteId(12));
/// ```
pub fn get_sent_memo_as_utf8(
data: &DataConnection,
data: &WalletDB,
id_note: NoteId,
) -> Result<Option<String>, SqliteClientError> {
let memo: Vec<_> = data.0.query_row(
@ -264,7 +264,7 @@ pub fn get_sent_memo_as_utf8(
}
pub fn block_height_extrema(
conn: &DataConnection,
conn: &WalletDB,
) -> Result<Option<(BlockHeight, BlockHeight)>, rusqlite::Error> {
conn.0
.query_row(
@ -285,7 +285,7 @@ pub fn block_height_extrema(
}
pub fn get_tx_height(
conn: &DataConnection,
conn: &WalletDB,
txid: TxId,
) -> Result<Option<BlockHeight>, rusqlite::Error> {
conn.0
@ -298,7 +298,7 @@ pub fn get_tx_height(
}
pub fn get_block_hash(
conn: &DataConnection,
conn: &WalletDB,
block_height: BlockHeight,
) -> Result<Option<BlockHash>, rusqlite::Error> {
conn.0
@ -318,7 +318,7 @@ pub fn get_block_hash(
/// If the requested height is greater than or equal to the height of the last scanned
/// block, this function does nothing.
pub fn rewind_to_height<P: consensus::Parameters>(
conn: &DataConnection,
conn: &WalletDB,
parameters: &P,
block_height: BlockHeight,
) -> Result<(), SqliteClientError> {
@ -369,7 +369,7 @@ pub fn rewind_to_height<P: consensus::Parameters>(
}
pub fn get_commitment_tree(
data: &DataConnection,
data: &WalletDB,
block_height: BlockHeight,
) -> Result<Option<CommitmentTree<Node>>, SqliteClientError> {
data.0
@ -392,7 +392,7 @@ pub fn get_commitment_tree(
}
pub fn get_witnesses(
data: &DataConnection,
data: &WalletDB,
block_height: BlockHeight,
) -> Result<Vec<(NoteId, IncrementalWitness<Node>)>, SqliteClientError> {
let mut stmt_fetch_witnesses = data
@ -416,7 +416,7 @@ pub fn get_witnesses(
}
pub fn get_nullifiers(
data: &DataConnection,
data: &WalletDB,
) -> Result<Vec<(Vec<u8>, AccountId)>, SqliteClientError> {
// Get the nullifiers for the notes we are tracking
let mut stmt_fetch_nullifiers = data
@ -451,7 +451,7 @@ mod tests {
use crate::{
tests,
wallet::init::{init_accounts_table, init_data_database},
AccountId, DataConnection,
AccountId, WalletDB,
};
use super::{get_address, get_balance};
@ -459,7 +459,7 @@ mod tests {
#[test]
fn empty_database_has_no_balance() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet

View File

@ -10,7 +10,7 @@ use zcash_primitives::{
use zcash_client_backend::{data_api::error::Error, encoding::encode_extended_full_viewing_key};
use crate::{address_from_extfvk, error::SqliteClientError, DataConnection};
use crate::{address_from_extfvk, error::SqliteClientError, WalletDB};
/// Sets up the internal structure of the data database.
///
@ -19,15 +19,15 @@ use crate::{address_from_extfvk, error::SqliteClientError, DataConnection};
/// ```
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::init::init_data_database,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file.path()).unwrap();
/// let db = WalletDB::for_path(data_file.path()).unwrap();
/// init_data_database(&db).unwrap();
/// ```
pub fn init_data_database(db_data: &DataConnection) -> Result<(), rusqlite::Error> {
pub fn init_data_database(db_data: &WalletDB) -> Result<(), rusqlite::Error> {
db_data.0.execute(
"CREATE TABLE IF NOT EXISTS accounts (
account INTEGER PRIMARY KEY,
@ -126,12 +126,12 @@ pub fn init_data_database(db_data: &DataConnection) -> Result<(), rusqlite::Erro
/// };
///
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::init::{init_accounts_table, init_data_database}
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db_data = DataConnection::for_path(data_file.path()).unwrap();
/// let db_data = WalletDB::for_path(data_file.path()).unwrap();
/// init_data_database(&db_data).unwrap();
///
/// let extsk = ExtendedSpendingKey::master(&[]);
@ -143,7 +143,7 @@ pub fn init_data_database(db_data: &DataConnection) -> Result<(), rusqlite::Erro
/// [`scan_cached_blocks`]: crate::scan::scan_cached_blocks
/// [`create_to_address`]: crate::transact::create_to_address
pub fn init_accounts_table<P: consensus::Parameters>(
data: &DataConnection,
data: &WalletDB,
params: &P,
extfvks: &[ExtendedFullViewingKey],
) -> Result<(), SqliteClientError> {
@ -191,7 +191,7 @@ pub fn init_accounts_table<P: consensus::Parameters>(
/// consensus::BlockHeight,
/// };
/// use zcash_client_sqlite::{
/// DataConnection,
/// WalletDB,
/// wallet::init::init_blocks_table,
/// };
///
@ -206,11 +206,11 @@ pub fn init_accounts_table<P: consensus::Parameters>(
/// let sapling_tree = &[];
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file.path()).unwrap();
/// let db = WalletDB::for_path(data_file.path()).unwrap();
/// init_blocks_table(&db, height, hash, time, sapling_tree);
/// ```
pub fn init_blocks_table(
data: &DataConnection,
data: &WalletDB,
height: BlockHeight,
hash: BlockHash,
time: u32,
@ -246,14 +246,14 @@ mod tests {
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
};
use crate::{tests, wallet::get_address, AccountId, DataConnection};
use crate::{tests, wallet::get_address, AccountId, WalletDB};
use super::{init_accounts_table, init_blocks_table, init_data_database};
#[test]
fn init_accounts_table_only_works_once() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// We can call the function as many times as we want with no data
@ -274,7 +274,7 @@ mod tests {
#[test]
fn init_blocks_table_only_works_once() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// First call with data should initialise the blocks table
@ -301,7 +301,7 @@ mod tests {
#[test]
fn init_accounts_table_stores_correct_address() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet

View File

@ -17,10 +17,10 @@ use zcash_client_backend::{
wallet::{AccountId, SpendableNote},
};
use crate::{error::SqliteClientError, DataConnection};
use crate::{error::SqliteClientError, WalletDB};
pub fn select_spendable_notes(
data: &DataConnection,
data: &WalletDB,
account: AccountId,
target_value: Amount,
anchor_height: BlockHeight,
@ -148,7 +148,7 @@ mod tests {
get_balance, get_verified_balance,
init::{init_accounts_table, init_blocks_table, init_data_database},
},
AccountId, CacheConnection, DataConnection,
AccountId, BlockDB, WalletDB,
};
fn test_prover() -> impl TxProver {
@ -163,7 +163,7 @@ mod tests {
#[test]
fn create_to_address_fails_on_incorrect_extsk() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add two accounts to the wallet
@ -211,7 +211,7 @@ mod tests {
#[test]
fn create_to_address_fails_with_no_blocks() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -240,7 +240,7 @@ mod tests {
#[test]
fn create_to_address_fails_on_insufficient_balance() {
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
init_blocks_table(
&db_data,
@ -283,11 +283,11 @@ mod tests {
#[test]
fn create_to_address_fails_on_unverified_notes() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -413,11 +413,11 @@ mod tests {
#[test]
fn create_to_address_fails_on_locked_notes() {
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet
@ -533,11 +533,11 @@ mod tests {
fn ovk_policy_prevents_recovery_from_chain() {
let network = tests::network();
let cache_file = NamedTempFile::new().unwrap();
let db_cache = CacheConnection(Connection::open(cache_file.path()).unwrap());
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
init_cache_database(&db_cache).unwrap();
let data_file = NamedTempFile::new().unwrap();
let db_data = DataConnection(Connection::open(data_file.path()).unwrap());
let db_data = WalletDB(Connection::open(data_file.path()).unwrap());
init_data_database(&db_data).unwrap();
// Add an account to the wallet