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

zcash_client_sqlite: Fix bugs & reduce complexity in scan progress computation. #1562

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ pub trait WalletTest: InputSource + WalletRead {
///
/// This type is opaque, and exists for use by tests defined in this crate.
#[cfg(any(test, feature = "test-dependencies"))]
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct OutputOfSentTx {
value: NonNegativeAmount,
Expand Down
16 changes: 6 additions & 10 deletions zcash_client_backend/src/data_api/testing/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,20 +881,16 @@ pub fn spend_fails_on_unverified_notes<T: ShieldedPoolTester>(
NonNegativeAmount::ZERO
);

// The account is configured without a recover-until height, so is by definition
// fully recovered, and we count 1 per pool for both numerator and denominator.
let fully_recovered = {
let n = 1;
#[cfg(feature = "orchard")]
let n = n * 2;
Some(Ratio::new(n, n))
};
// If none of the wallet's accounts have a recover-until height, then there
// is no recovery phase for the wallet, and therefore the denominator in the
// resulting ratio (the number of notes in the recovery range) is zero.
let no_recovery = Some(Ratio::new(0, 0));

// Wallet is fully scanned
let summary = st.get_wallet_summary(1);
assert_eq!(
summary.as_ref().and_then(|s| s.recovery_progress()),
fully_recovered,
no_recovery,
);
assert_eq!(
summary.and_then(|s| s.scan_progress()),
Expand All @@ -915,7 +911,7 @@ pub fn spend_fails_on_unverified_notes<T: ShieldedPoolTester>(
let summary = st.get_wallet_summary(1);
assert_eq!(
summary.as_ref().and_then(|s| s.recovery_progress()),
fully_recovered
no_recovery
);
assert_eq!(
summary.and_then(|s| s.scan_progress()),
Expand Down
Loading
Loading