Skip to content

Commit

Permalink
Merge pull request #1543 from zcash/zcb-migrate-tests
Browse files Browse the repository at this point in the history
Move remaining pool tests from `zcash_client_sqlite` to `zcash_client_backend`
  • Loading branch information
nuttycom authored Sep 21, 2024
2 parents c0f4eff + e67e7ab commit 778fe2e
Show file tree
Hide file tree
Showing 10 changed files with 2,676 additions and 2,324 deletions.
1 change: 1 addition & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this library adheres to Rust's notion of

### Added
- `zcash_client_backend::data_api`:
- `GAP_LIMIT`
- `WalletSummary::recovery_progress`

### Changed
Expand Down
55 changes: 47 additions & 8 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ pub const SAPLING_SHARD_HEIGHT: u8 = sapling::NOTE_COMMITMENT_TREE_DEPTH / 2;
#[cfg(feature = "orchard")]
pub const ORCHARD_SHARD_HEIGHT: u8 = { orchard::NOTE_COMMITMENT_TREE_DEPTH as u8 } / 2;

/// The number of ephemeral addresses that can be safely reserved without observing any
/// of them to be mined. This is the same as the gap limit in Bitcoin.
pub const GAP_LIMIT: u32 = 20;

/// An enumeration of constraints that can be applied when querying for nullifiers for notes
/// belonging to the wallet.
pub enum NullifierQuery {
Expand Down Expand Up @@ -1113,7 +1117,7 @@ pub trait WalletRead {

/// Returns a vector of ephemeral transparent addresses associated with the given
/// account controlled by this wallet, along with their metadata. The result includes
/// reserved addresses, and addresses for `GAP_LIMIT` additional indices (capped to
/// reserved addresses, and addresses for [`GAP_LIMIT`] additional indices (capped to
/// the maximum index).
///
/// If `index_range` is some `Range`, it limits the result to addresses with indices
Expand Down Expand Up @@ -1208,27 +1212,62 @@ pub trait WalletRead {
/// of the [`testing`] framework. They should not be used in production software.
#[cfg(any(test, feature = "test-dependencies"))]
#[delegatable_trait]
pub trait WalletTest: WalletRead {
pub trait WalletTest: InputSource + WalletRead {
/// Returns a vector of transaction summaries.
///
/// Currently test-only, as production use could return a very large number of results; either
/// pagination or a streaming design will be necessary to stabilize this feature for production
/// use.
fn get_tx_history(
&self,
) -> Result<Vec<testing::TransactionSummary<Self::AccountId>>, Self::Error> {
Ok(vec![])
}
) -> Result<
Vec<testing::TransactionSummary<<Self as WalletRead>::AccountId>>,
<Self as WalletRead>::Error,
>;

/// Returns the note IDs for shielded notes sent by the wallet in a particular
/// transaction.
fn get_sent_note_ids(
&self,
_txid: &TxId,
_protocol: ShieldedProtocol,
) -> Result<Vec<NoteId>, Self::Error> {
Ok(vec![])
}
) -> Result<Vec<NoteId>, <Self as WalletRead>::Error>;

#[allow(clippy::type_complexity)]
fn get_confirmed_sends(
&self,
txid: &TxId,
) -> Result<Vec<(u64, Option<String>, Option<String>, Option<u32>)>, <Self as WalletRead>::Error>;

#[allow(clippy::type_complexity)]
fn get_checkpoint_history(
&self,
) -> Result<
Vec<(
BlockHeight,
ShieldedProtocol,
Option<incrementalmerkletree::Position>,
)>,
<Self as WalletRead>::Error,
>;

/// Fetches the transparent output corresponding to the provided `outpoint`.
/// Allows selecting unspendable outputs for testing purposes.
///
/// Returns `Ok(None)` if the UTXO is not known to belong to the wallet or is not
/// spendable as of the chain tip height.
#[cfg(feature = "transparent-inputs")]
fn get_transparent_output(
&self,
outpoint: &OutPoint,
allow_unspendable: bool,
) -> Result<Option<WalletTransparentOutput>, <Self as InputSource>::Error>;

/// Returns all the notes that have been received by the wallet.
fn get_notes(
&self,
protocol: ShieldedProtocol,
) -> Result<Vec<ReceivedNote<Self::NoteRef, Note>>, <Self as InputSource>::Error>;
}

/// The relevance of a seed to a given wallet.
Expand Down
Loading

0 comments on commit 778fe2e

Please sign in to comment.