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

Generalize the zcash_client_sqlite test framework and extract it to zcash_client_backend #1530

Merged
merged 19 commits into from
Sep 10, 2024

Conversation

nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Sep 5, 2024

As a side-effect, this fixes #1260.

@nuttycom nuttycom force-pushed the generalized_test_framework branch from 6b6b310 to 33ba129 Compare September 5, 2024 21:36
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 67.52874% with 339 lines in your changes missing coverage. Please review.

Project coverage is 61.26%. Comparing base (db06580) to head (cd71c30).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
zcash_client_backend/src/data_api/testing.rs 66.12% 271 Missing ⚠️
...ash_client_backend/src/data_api/testing/orchard.rs 0.00% 30 Missing ⚠️
zcash_client_sqlite/src/wallet.rs 65.71% 12 Missing ⚠️
zcash_client_sqlite/src/lib.rs 61.53% 10 Missing ⚠️
zcash_client_backend/src/data_api/testing/pool.rs 91.30% 8 Missing ⚠️
zcash_client_backend/src/data_api.rs 25.00% 6 Missing ⚠️
...ash_client_backend/src/data_api/testing/sapling.rs 95.91% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1530      +/-   ##
==========================================
+ Coverage   61.07%   61.26%   +0.18%     
==========================================
  Files         142      146       +4     
  Lines       16710    16890     +180     
==========================================
+ Hits        10205    10347     +142     
- Misses       6505     6543      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nuttycom nuttycom marked this pull request as ready for review September 6, 2024 03:52
@nuttycom nuttycom requested review from str4d and daira September 6, 2024 04:06
@nuttycom nuttycom force-pushed the generalized_test_framework branch from 647c266 to 4a3a52b Compare September 6, 2024 14:44
@nuttycom nuttycom force-pushed the generalized_test_framework branch from baade4f to f2654f5 Compare September 6, 2024 19:33
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Reviewed d4e26d5.

@@ -346,9 +346,11 @@ pub enum AccountSource {
}

/// A set of capabilities that a client account must provide.
pub trait Account<AccountId: Copy> {
pub trait Account {
type AccountId: Copy;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this made a type parameter in the first place? I can't immediately think of a reason why an implementation of the Data Access API would have two different Account implementations with different IDs.

@@ -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>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Document this addition in the changelog (it was added in the ambassador commit and IDK why yet).

Copy link
Contributor

Choose a reason for hiding this comment

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

It is used in conjunction with the fix to #1260 inside the implementation of ShieldedPoolTester for Sapling (and similarly for Orchard). So it could instead be made crate-private now that SaplingPoolTester is also in zcash_client_backend instead of documenting it as an addition.

/// 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>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Document this addition in the changelog (it was added in the ambassador commit and IDK why yet).

anchor_height,
exclude,
)?,
if sources.contains(&ShieldedProtocol::Sapling) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit (db6b970) silently fixes #1260.

zcash_client_sqlite/src/testing/db.rs Outdated Show resolved Hide resolved

use super::{pool::ShieldedPoolTester, TestState};

pub struct SaplingPoolTester;
Copy link
Contributor

Choose a reason for hiding this comment

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

The struct needs documentation now that it is in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #1539.


/// Trait that exposes the pool-specific types and operations necessary to run the
/// single-shielded-pool tests on a given pool.
pub trait ShieldedPoolTester {
Copy link
Contributor

Choose a reason for hiding this comment

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

The trait's associated types and methods need documentation now that it is in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #1539.

wallet::{Note, ReceivedNote},
};

pub struct OrchardPoolTester;
Copy link
Contributor

Choose a reason for hiding this comment

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

The struct needs documentation now that it is in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #1539.

zcash_client_backend/src/data_api/testing.rs Show resolved Hide resolved
@@ -88,3 +98,143 @@ pub trait ShieldedPoolTester {

fn received_note_count(summary: &ScanSummary) -> usize;
}

pub fn send_single_step_proposed_transfer<T: ShieldedPoolTester>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs documentation now that it is in the public API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #1539.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

ACK cd71c30. The remaining review comments are doc-only, and will be addressed in a subsequent PR.

@str4d str4d merged commit c97e9a1 into zcash:main Sep 10, 2024
27 checks passed
str4d added a commit that referenced this pull request Sep 16, 2024
str4d added a commit that referenced this pull request Sep 16, 2024
str4d added a commit that referenced this pull request Sep 16, 2024
@nuttycom nuttycom deleted the generalized_test_framework branch September 20, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zcash_client_sqlite: Fix select_spendable_notes to not ignore the sources parameter
3 participants