Skip to content

Conversation

@schell
Copy link
Contributor

@schell schell commented Oct 24, 2025

This PR introduces a wrapper over TestBuilder and TestState that provides a scenario-driven API with which to create tests that are easily grokked.

So far the test API covers the "add funds" portion of a test scenario.

Existing tests were refactored in terms of this DSL where appropriate.

@schell schell force-pushed the chore/pool-testing-dsl branch 3 times, most recently from 48e226e to 1b1a6c1 Compare November 4, 2025 22:28
@schell schell marked this pull request as ready for review November 5, 2025 03:32
@schell schell requested review from nuttycom and str4d and removed request for nuttycom November 5, 2025 03:32
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 89.45455% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.73%. Comparing base (a40ee35) to head (a3dfd9e).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
zcash_client_backend/src/data_api/testing/pool.rs 88.88% 18 Missing ⚠️
...sh_client_backend/src/data_api/testing/pool/dsl.rs 89.81% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2011      +/-   ##
==========================================
- Coverage   67.95%   67.73%   -0.23%     
==========================================
  Files         213      214       +1     
  Lines       28972    28742     -230     
==========================================
- Hits        19688    19468     -220     
+ Misses       9284     9274      -10     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@schell schell requested a review from daira November 13, 2025 02:03
daira
daira previously approved these changes Nov 13, 2025
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with minor suggestions.

Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

Blocking on opportunity to review - I will try to get to this today.

/// - Attempts to construct a request to spend the whole balance to an external address in the
/// same pool.
/// - succeds at doing so
// TODO(schell): as far as I can tell this function is unused in our test suite
Copy link
Contributor

Choose a reason for hiding this comment

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

That's probably a bug. It should be called in the same pattern as the other functions in this module. This is quite error-prone (it's easy to forget to call a test) and I'd like to find a better way of doing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't have any uses of this, we should add one and see whether it passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test for this function on main and it does not pass. I'm guessing that's why it's currently unused?

daira
daira previously approved these changes Nov 18, 2025
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with a non-blocking comment. If that comment is not resolved then please file an issue about it. This does not override @nuttycom's request to wait for his review.

refactored TestState::generate_next_block in terms of TestState::generate_next_block_multi
TestDsl::add_notes_to now takes a generic iterator of notes
nuttycom
nuttycom previously approved these changes Nov 24, 2025
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK with naming nits. Also, I would prefer that the DSF -> Dsf capitalization change be reverted because it makes the diff here noisier than it needs to be.

Comment on lines +321 to +317
if note_config.value > zip317::MARGINAL_FEE {
// Don't include uneconomic (dust) notes in the expected
// total, as the balance won't include them.
expected_total = (expected_total + note_config.value).unwrap();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a weird place to hardcode this behavior. Maybe the dust threshold should at least be part of the builder, but when we add the ability to consume dust notes in grace inputs then even that would likely break.

Maybe this is okay for now, but it seems like something that will be annoying to track down from test failures if we change how balance calculation is done.

This would be fine if this reflected the documented semantics of balance calculation, but I'm not sure that the balance calculation APIs currently document such a contract.

/// - Attempts to construct a request to spend the whole balance to an external address in the
/// same pool.
/// - succeds at doing so
// TODO(schell): as far as I can tell this function is unused in our test suite
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't have any uses of this, we should add one and see whether it passes.

…renamed TestDsl::with_standard_sapling_account to TestDsl::with_sapling_birthday_account
@schell schell dismissed stale reviews from nuttycom and daira via 3645510 November 24, 2025 23:34
@schell schell force-pushed the chore/pool-testing-dsl branch from 5270ee1 to 3645510 Compare November 24, 2025 23:34
@schell schell requested review from daira and nuttycom November 25, 2025 02:10
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK a3dfd9e, nice delta!

@nuttycom nuttycom merged commit 0885877 into main Nov 25, 2025
48 checks passed
@nuttycom nuttycom deleted the chore/pool-testing-dsl branch November 25, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet