zcash_client_backend: Make `data_api` traits delegatable via `ambassador` for testing.
This commit is contained in:
parent
69953ccd88
commit
0ae5ac1a99
|
@ -67,6 +67,18 @@ version = "0.2.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
||||
|
||||
[[package]]
|
||||
name = "ambassador"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b27ba24e4d8a188489d5a03c7fabc167a60809a383cdb4d15feb37479cd2a48"
|
||||
dependencies = [
|
||||
"itertools 0.10.5",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "amplify"
|
||||
version = "4.6.0"
|
||||
|
@ -5817,6 +5829,7 @@ dependencies = [
|
|||
name = "zcash_client_backend"
|
||||
version = "0.13.0"
|
||||
dependencies = [
|
||||
"ambassador",
|
||||
"arti-client",
|
||||
"assert_matches",
|
||||
"async-trait",
|
||||
|
@ -5879,6 +5892,7 @@ dependencies = [
|
|||
name = "zcash_client_sqlite"
|
||||
version = "0.11.2"
|
||||
dependencies = [
|
||||
"ambassador",
|
||||
"assert_matches",
|
||||
"bip32",
|
||||
"bls12_381",
|
||||
|
|
|
@ -133,6 +133,7 @@ lazy_static = "1"
|
|||
static_assertions = "1"
|
||||
|
||||
# Tests and benchmarks
|
||||
ambassador = "0.4"
|
||||
assert_matches = "1.5"
|
||||
criterion = "0.5"
|
||||
proptest = "1"
|
||||
|
|
|
@ -91,6 +91,7 @@ shardtree.workspace = true
|
|||
# - Test dependencies
|
||||
proptest = { workspace = true, optional = true }
|
||||
jubjub = { workspace = true, optional = true }
|
||||
ambassador = { workspace = true, optional = true }
|
||||
|
||||
# - ZIP 321
|
||||
nom = "7"
|
||||
|
@ -195,6 +196,7 @@ tor = [
|
|||
|
||||
## Exposes APIs that are useful for testing, such as `proptest` strategies.
|
||||
test-dependencies = [
|
||||
"dep:ambassador",
|
||||
"dep:proptest",
|
||||
"dep:jubjub",
|
||||
"orchard?/test-dependencies",
|
||||
|
|
|
@ -103,7 +103,7 @@ use {
|
|||
};
|
||||
|
||||
#[cfg(any(test, feature = "test-dependencies"))]
|
||||
use zcash_primitives::consensus::NetworkUpgrade;
|
||||
use {ambassador::delegatable_trait, zcash_primitives::consensus::NetworkUpgrade};
|
||||
|
||||
pub mod chain;
|
||||
pub mod error;
|
||||
|
@ -662,12 +662,22 @@ impl<NoteRef> SpendableNotes<NoteRef> {
|
|||
self.sapling.as_ref()
|
||||
}
|
||||
|
||||
/// Consumes this value and returns the Sapling notes contained within it.
|
||||
pub fn take_sapling(self) -> Vec<ReceivedNote<NoteRef, sapling::Note>> {
|
||||
self.sapling
|
||||
}
|
||||
|
||||
/// Returns the set of spendable Orchard notes.
|
||||
#[cfg(feature = "orchard")]
|
||||
pub fn orchard(&self) -> &[ReceivedNote<NoteRef, orchard::note::Note>] {
|
||||
self.orchard.as_ref()
|
||||
}
|
||||
|
||||
/// Consumes this value and returns the Orchard notes contained within it.
|
||||
pub fn take_orchard(self) -> Vec<ReceivedNote<NoteRef, orchard::note::Note>> {
|
||||
self.orchard
|
||||
}
|
||||
|
||||
/// Computes the total value of Sapling notes.
|
||||
pub fn sapling_value(&self) -> Result<NonNegativeAmount, BalanceError> {
|
||||
self.sapling
|
||||
|
@ -721,6 +731,7 @@ impl<NoteRef> SpendableNotes<NoteRef> {
|
|||
|
||||
/// A trait representing the capability to query a data store for unspent transaction outputs
|
||||
/// belonging to a wallet.
|
||||
#[cfg_attr(feature = "test-dependencies", delegatable_trait)]
|
||||
pub trait InputSource {
|
||||
/// The type of errors produced by a wallet backend.
|
||||
type Error: Debug;
|
||||
|
@ -798,6 +809,7 @@ pub trait InputSource {
|
|||
/// This trait defines the read-only portion of the storage interface atop which
|
||||
/// higher-level wallet operations are implemented. It serves to allow wallet functions to
|
||||
/// be abstracted away from any particular data storage substrate.
|
||||
#[cfg_attr(feature = "test-dependencies", delegatable_trait)]
|
||||
pub trait WalletRead {
|
||||
/// The type of errors that may be generated when querying a wallet data store.
|
||||
type Error: Debug;
|
||||
|
@ -1773,6 +1785,7 @@ impl AccountBirthday {
|
|||
/// [zcash/librustzcash#1284]: https://github.com/zcash/librustzcash/issues/1284
|
||||
/// [BIP 39]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
|
||||
/// [`bip0039`]: https://crates.io/crates/bip0039
|
||||
#[cfg_attr(feature = "test-dependencies", delegatable_trait)]
|
||||
pub trait WalletWrite: WalletRead {
|
||||
/// The type of identifiers used to look up transparent UTXOs.
|
||||
type UtxoRef;
|
||||
|
@ -1974,9 +1987,7 @@ pub trait WalletWrite: WalletRead {
|
|||
}
|
||||
|
||||
/// This trait describes a capability for manipulating wallet note commitment trees.
|
||||
///
|
||||
/// At present, this only serves the Sapling protocol, but it will be modified to
|
||||
/// also provide operations related to Orchard note commitment trees in the future.
|
||||
#[cfg_attr(feature = "test-dependencies", delegatable_trait)]
|
||||
pub trait WalletCommitmentTrees {
|
||||
type Error: Debug;
|
||||
|
||||
|
|
Loading…
Reference in New Issue