Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move remaining pool tests from zcash_client_sqlite to zcash_client_backend #1543

Merged
merged 4 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the inner result type here be a struct? I have no idea what this tuple means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be nicer. I pulled this API as-is from #1533. We also need to add documentation etc. to the new APIs in this PR, which includes All Of The Tests (but I'd spent long enough on this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #1544.


#[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
Loading