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

Add proptest-impl feature to zebra-state #2529

Merged
merged 8 commits into from
Jul 28, 2021

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Jul 26, 2021

Motivation

The zebra-state crate was previously already using #[cfg(feature = "proptest-impl")] feature gates, but it didn't have the proptest-impl feature defined in Cargo.toml. This became necessary as part of the work for #1334, because having a zebra_state::init_test helper function to be used for tests on other crates would simplify some code.

Solution

The proptest-impl feature was added, and it enables the zebra-test and the proptest dependencies with it.

Unfortunately, just adding the feature breaks the build, because the code had partial usages of the feature already. Therefore, some refactoring was needed to fix the errors and also eliminate warnings.

Review

@teor2345 had already started looking at the #2519 draft PR for #1334.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

A PR after this one will add the zebra_state::init_test helper function and refactor some other crates' test code to use it.


This change is Reviewable

@jvff jvff requested a review from teor2345 July 26, 2021 20:13
@zfnd-bot zfnd-bot bot assigned jvff Jul 26, 2021
This prepares the `zebra-state` crate to be able to export some
test-specific helper types and functions.
@jvff jvff force-pushed the zebra-state-proptest-impl-feature branch from 33bf540 to 6279dfa Compare July 26, 2021 20:57
@teor2345

This comment has been minimized.

jvff added 3 commits July 27, 2021 12:04
A separate module to contain the `Prepare` trait, since it's required by
some prop-test strategies and therefore can't be in the `tests` module.
Use the same trait but placed in a new module that's accessible based on
the feature flag.
It was obsoleted by the new copy in the `arbitrary` module.
@jvff jvff force-pushed the zebra-state-proptest-impl-feature branch from 6279dfa to 1b84d40 Compare July 27, 2021 12:04
jvff added 3 commits July 27, 2021 12:44
Prepare for it to be accessible in some test modules.
Import the function directly, instead of just its containing module.
Create a new module for the strategy functions that are only used
internally.
@jvff jvff force-pushed the zebra-state-proptest-impl-feature branch from 1b84d40 to 71e9a6b Compare July 27, 2021 12:47
Copy link
Contributor Author

@jvff jvff left a comment

Choose a reason for hiding this comment

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

It looks like the new arbitrary.rs file is missing from this branch?

Oops, my bad 😓 Fixed now.

Reviewable status: 0 of 13 files reviewed, 1 unresolved discussion (waiting on @jvff and @teor2345)


zebra-state/src/service/arbitrary.rs, line 151 at r1 (raw file):

Previously, teor2345 (teor) wrote…

It's a bit confusing mixing #[cfg(test)] and #[cfg(any(test, feature = "proptest-impl"))] code in the same module.

Can you move these functions and their imports to a new tests::setup module instead?

Done.

@teor2345 teor2345 enabled auto-merge (squash) July 27, 2021 23:26
@teor2345 teor2345 merged commit 76b70fb into ZcashFoundation:main Jul 28, 2021
@jvff jvff deleted the zebra-state-proptest-impl-feature branch July 28, 2021 01:01
mpguerra added a commit that referenced this pull request Jul 28, 2021
mpguerra added a commit that referenced this pull request Jul 29, 2021
* Draft CHANGELOG for Zebra 1.0.0-alpha.14

* Add PR #2533 to CHANGELOG

* Apply suggestions from code review

Co-authored-by: teor <[email protected]>

* Remove entry about updating the changelog

* move #2497

* add #2529

* Add a missing space

* Add #2458, #2525, #2486, #2542 and  #2539 to CHANGELOG

Co-authored-by: teor <[email protected]>
Co-authored-by: Deirdre Connolly <[email protected]>
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.

3 participants