Fix test/doctest errors.

This commit is contained in:
Kris Nuttycombe 2020-09-11 16:17:43 -06:00
parent 2e2f34b033
commit f742895118
9 changed files with 28 additions and 22 deletions

View File

@ -1,3 +1,5 @@
use std::fmt::Debug;
use zcash_primitives::{
block::BlockHash,
consensus::{self, BlockHeight, NetworkUpgrade},
@ -141,7 +143,7 @@ where
P: consensus::Parameters,
C: CacheOps<Error = E>,
&'db D: DBOps<Error = E, NoteRef = N>,
N: Copy,
N: Copy + Debug,
E: From<Error<E0, N>>,
{
let sapling_activation_height = params
@ -155,7 +157,7 @@ where
.unwrap_or(sapling_activation_height - 1)
})?;
// Raise SQL errors from the query, IO errors from parsing, and incorrect HRP errors.
// Fetch the ExtendedFullViewingKeys we are tracking
let extfvks = data.get_extended_full_viewing_keys(params)?;
// Get the most recent CommitmentTree

View File

@ -1,4 +1,5 @@
use std::cmp;
use std::fmt::Debug;
use zcash_primitives::{
block::BlockHash,
@ -25,8 +26,8 @@ pub mod wallet;
pub trait DBOps {
type Error;
type NoteRef: Copy; // Backend-specific note identifier
type TxRef: Copy;
type NoteRef: Copy + Debug; // Backend-specific note identifier
type TxRef: Copy + Debug;
type UpdateOps: DBUpdate<Error = Self::Error, NoteRef = Self::NoteRef, TxRef = Self::TxRef>;
fn block_height_extrema(&self) -> Result<Option<(BlockHeight, BlockHeight)>, Self::Error>;

View File

@ -1,4 +1,5 @@
//! Functions for scanning the chain and extracting relevant information.
use std::fmt::Debug;
use zcash_primitives::{
consensus::{self, BranchId, NetworkUpgrade},
@ -157,7 +158,7 @@ pub fn create_spend_to_address<'db, E0, N, E, P, D, R>(
where
E0: Into<Error<E, N>>,
P: consensus::Parameters + Clone,
R: Copy,
R: Copy + Debug,
&'db D: DBOps<Error = E0, TxRef = R>,
{
// Check that the ExtendedSpendingKey we have been given corresponds to the

View File

@ -12,7 +12,7 @@ use crate::CacheConnection;
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// CacheConnection,
/// init::init_cache_database,
/// chain::init::init_cache_database,
/// };
///
/// let cache_file = NamedTempFile::new().unwrap();

View File

@ -18,8 +18,9 @@
//! }
//! };
//!
//! use crate::{
//! use zcash_client_sqlite::{
//! CacheConnection,
//! DataConnection,
//! wallet::{rewind_to_height},
//! };
//!

View File

@ -376,8 +376,8 @@ impl<'a> DBUpdate for DataConnStmtCache<'a> {
// It isn't there, so insert our transaction into the database.
self.stmt_insert_tx_data.execute(&[
txid.to_sql()?,
u32::from(tx.expiry_height).to_sql()?,
created_at.to_sql()?,
u32::from(tx.expiry_height).to_sql()?,
raw_tx.to_sql()?,
])?;

View File

@ -20,7 +20,7 @@ use crate::{address_from_extfvk, error::SqliteClientError, DataConnection};
/// use tempfile::NamedTempFile;
/// use zcash_client_sqlite::{
/// DataConnection,
/// init::init_data_database,
/// wallet::init::init_data_database,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
@ -127,7 +127,7 @@ pub fn init_data_database(db_data: &DataConnection) -> Result<(), rusqlite::Erro
///
/// use zcash_client_sqlite::{
/// DataConnection,
/// init::{init_accounts_table, init_data_database}
/// wallet::init::{init_accounts_table, init_data_database}
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
@ -192,11 +192,11 @@ pub fn init_accounts_table<P: consensus::Parameters>(
/// };
/// use zcash_client_sqlite::{
/// DataConnection,
/// init::init_blocks_table,
/// wallet::init::init_blocks_table,
/// };
///
/// // The block height.
/// let height = BlockHeight(500_000);
/// let height = BlockHeight::from_u32(500_000);
/// // The hash of the block header.
/// let hash = BlockHash([0; 32]);
/// // The nTime field from the block header.

View File

@ -34,10 +34,10 @@ pub mod transact;
/// use zcash_primitives::{
/// consensus::{self, Network},
/// };
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// AccountId,
/// DataConnection,
/// query::get_address,
/// wallet::get_address,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
@ -117,10 +117,10 @@ pub fn is_valid_account_extfvk<P: consensus::Parameters>(
///
/// ```
/// use tempfile::NamedTempFile;
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// AccountId,
/// DataConnection,
/// query::get_balance,
/// wallet::get_balance,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
@ -151,15 +151,16 @@ pub fn get_balance(data: &DataConnection, account: AccountId) -> Result<Amount,
///
/// ```
/// use tempfile::NamedTempFile;
/// use zcash_primitives::consensus::{BlockHeight};
/// use zcash_client_backend::api::AccountId;
/// use zcash_client_sqlite::{
/// AccountId,
/// DataConnection,
/// query::get_verified_balance,
/// wallet::get_verified_balance,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
/// let db = DataConnection::for_path(data_file).unwrap();
/// let addr = get_verified_balance(&db, AccountId(0));
/// let addr = get_verified_balance(&db, AccountId(0), BlockHeight::from_u32(0));
/// ```
pub fn get_verified_balance(
data: &DataConnection,
@ -194,7 +195,7 @@ pub fn get_verified_balance(
/// use zcash_client_sqlite::{
/// NoteId,
/// DataConnection,
/// query::get_received_memo_as_utf8,
/// wallet::get_received_memo_as_utf8,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();
@ -234,7 +235,7 @@ pub fn get_received_memo_as_utf8(
/// use zcash_client_sqlite::{
/// NoteId,
/// DataConnection,
/// query::get_sent_memo_as_utf8,
/// wallet::get_sent_memo_as_utf8,
/// };
///
/// let data_file = NamedTempFile::new().unwrap();

View File

@ -1,7 +1,7 @@
//! Functions for creating transactions.
//!
use std::convert::TryInto;
use rusqlite::named_params;
use std::convert::TryInto;
use ff::PrimeField;