-
Notifications
You must be signed in to change notification settings - Fork 250
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
Migrate all zcash_client_sqlite
pool tests to zcash_client_backend
and make them generic over backend implementation
#1533
Conversation
/// 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. | ||
#[cfg(feature = "transparent-inputs")] | ||
pub(crate) const GAP_LIMIT: u32 = 20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong elsewhere maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; it can't live under zcash_client_backend::data_api_testing
as that's only accessible with the test-dependencies
feature flag.
); | ||
// previously it was hard-coded to a SqlClientError which could check the index | ||
// not sure how best to handle this in a generic way | ||
// Err(SqliteClientError::ReachedGapLimit(acct, bad_index)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on how to handle checking for specific errors like this in the back-end agnostic case?
|
||
/// Return the notes with a given value | ||
#[cfg(any(test, feature = "test-dependencies"))] | ||
fn get_notes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #1539 I'm moving these to a dedicated WalletTest
trait so we can freely expose whatever internals are needed for testing purposes. (I'll handle any conflicts.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual commits are structured as if they should be preserved, but they are currently unreviewable. Please fix the commits in the PR to be reviewable (which may amount to squashing all the commits together and then optionally splitting the resulting commit into functional parts).
zcash_client_sqlite/src/wallet.rs
Outdated
@@ -3194,6 +3194,7 @@ pub mod testing { | |||
|
|||
let results = stmt | |||
.query_and_then::<TransactionSummary<AccountId>, SqliteClientError, _, _>([], |row| { | |||
let raw_tx: Vec<u8> = row.get("raw")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break (either loudly, or silently with an empty Vec
which is a bad failure mode), as the raw
column is nullable.
let raw_tx: Vec<u8> = row.get("raw")?; | |
let raw_tx: Option<Vec<u8>> = row.get("raw")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And indeed this was reverted in a later commit as broken. I cannot tell from the current commits why this was initially considered necessary, and why it is no longer needed.
@@ -570,1247 +570,127 @@ pub(crate) fn change_note_spends_succeed<T: ShieldedPoolTester>() { | |||
) | |||
} | |||
|
|||
pub(crate) fn external_address_change_spends_detected_in_restore_from_seed< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix this third commit (ad30ad6):
- Commit message is
remove the raw field on get_tx_history as it broke tests
but the raw field is not removed. - A bunch of test content is deleted, with no visible move.
In order to review this PR, I need the code moves to be in the same commit, so that git show COMMIT --color-moved=zebra --color-moved-ws=allow-indentation-change
works. Ideally the commit is as much a pure move as possible, with a fixup commit afterwards, but if the fixups are trivial then doing both at once is okayish.
@@ -100,7 +100,6 @@ pub struct TransactionSummary<AccountId> { | |||
memo_count: usize, | |||
expired_unmined: bool, | |||
is_shielding: bool, | |||
raw: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The raw
removal is in the fourth commit (bb4dd30) instead of the third, but the fix is probably to rewrite the fourth commit's message (and separately fixup or remove the third commit per my previous comment).
// Now scan the block in which we received the note that was spent. | ||
st.scan_cached_blocks(received_height, 1); | ||
|
||
// Account balance should be the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit (bb4dd30) appears to be uncommenting a large amount of test code? I cannot figure out whether any of the uncommented code is part of the fix issue querying notes
that the commit message says is going on.
Given that there are thousands of lines changed as a result of doing so, please uncomment the code in one commit, and then in a second commit make changes to it.
@@ -238,3 +240,2302 @@ pub fn send_single_step_proposed_transfer<T: ShieldedPoolTester>( | |||
Ok(_) | |||
); | |||
} | |||
|
|||
// #[cfg(feature = "transparent-inputs")] | |||
// pub(crate) fn send_multi_step_proposed_transfer<T: ShieldedPoolTester>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. Is what you did copy across all of the code, and comment it out at the destination in the same commit? Please do not do that, as the current approach makes it impossible to review the move.
Instead, either copy all the code as-is in one move (creating a commit that fails to compile) and then in subsequent commits apply the fixes, or move individual test functions over in one commit at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flushing a couple of comments from the review I started before @str4d's; I will re-review once the commit history is cleaned up to make it easier to see the moves.
.block_height(), | ||
h | ||
); | ||
assert_eq!(self.get_spendable_balance(account_id, 1), value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion being embedded here is a bit surprising, because a caller could reasonably expect to be able to call this in locations other than just at the start of a test.
@@ -238,3 +240,2302 @@ pub fn send_single_step_proposed_transfer<T: ShieldedPoolTester>( | |||
Ok(_) | |||
); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I'm reviewing this commit-by-commit, I'm surprised to see this copied in commented out here. I presume that it will be uncommented in a later commit, but it would b easier to evaluate the diff if the move were done in a single commit.
OvkPolicy::Sender, | ||
&frobbed_proposal, | ||
); | ||
// TODO: Figure out how we want to handle different kinds of errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it clear that some of our error infrastructure needs to be refactored such that the persistence-specific errors are separate from the domain errors; right now SqliteClientError
mixes the two. This is a somewhat invasive change though. It might make sense to just assert that there is an error for now, with the goal of later being able to uncomment this code once that refactoring has been performed; these TODOs can serve as motivation to get that done - maybe upgrade them to FIXMEs.
Replaced by #1543. |
Moves the tests across, modifying where required and makes some additional changes to the
data_api
trait methods to support the test use-cases