export proptest impls for use in downstream crates (#1092)

* export proptest impls for use in downstream crates

* add testjob for disabled feature in zebra-chain

* run rustfmt

* try to fix github actions syntax

* differentiate name

* prove that github action tests zebra-chain build without features

* revert change from last commit now that test is running

* remove accidentally introduced newline

* Update .github/workflows/ci.yml

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>

Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
This commit is contained in:
Jane Lusby 2020-09-23 18:52:52 -07:00 committed by GitHub
parent 40e22808c7
commit 0b4e974c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 151 additions and 87 deletions

View File

@ -1,7 +1,6 @@
name: CI
on: pull_request
jobs:
test:
@ -32,6 +31,25 @@ jobs:
command: test
args: --verbose --all
build-chain-no-features:
name: Build zebra-chain w/o features on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: Run build without features enabled
working-directory: ./zebra-chain
env:
RUST_BACKTRACE: full
run: cargo build --verbose --no-default-features
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

1
Cargo.lock generated
View File

@ -3282,6 +3282,7 @@ dependencies = [
"lazy_static",
"owo-colors",
"pretty_assertions",
"proptest",
"regex",
"spandoc",
"thiserror",

View File

@ -7,6 +7,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = []
proptest-impl = ["proptest", "proptest-derive"]
[dependencies]
bech32 = "0.7.2"
bitvec = "0.17.4"
@ -29,6 +34,9 @@ sha2 = { version = "0.9.1", features=["compress"] }
thiserror = "1"
x25519-dalek = { version = "1.1", features = ["serde"] }
proptest = { version = "0.10", optional = true }
proptest-derive = { version = "0.2.0", optional = true }
# ZF deps
displaydoc = "0.1.7"
ed25519-zebra = "1"
@ -39,9 +47,9 @@ bitflags = "1.2.1"
[dev-dependencies]
bincode = "1"
color-eyre = "0.5"
proptest = "0.10"
proptest-derive = "0.2.0"
spandoc = "0.2"
tracing = "0.1.19"
proptest = "0.10"
proptest-derive = "0.2"
zebra-test = { path = "../zebra-test/" }

View File

@ -296,25 +296,26 @@ impl ZcashDeserialize for Amount<NonNegative> {
}
}
#[cfg(any(test, feature = "proptest-impl"))]
use proptest::prelude::*;
#[cfg(any(test, feature = "proptest-impl"))]
impl<C> Arbitrary for Amount<C>
where
C: Constraint + std::fmt::Debug,
{
type Parameters = ();
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
C::valid_range().prop_map(|v| Self(v, PhantomData)).boxed()
}
type Strategy = BoxedStrategy<Self>;
}
#[cfg(test)]
mod test {
use super::*;
use color_eyre::eyre::Result;
use proptest::prelude::*;
use std::fmt;
impl<C> Arbitrary for Amount<C>
where
C: Constraint + fmt::Debug,
{
type Parameters = ();
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
C::valid_range().prop_map(|v| Self(v, PhantomData)).boxed()
}
type Strategy = BoxedStrategy<Self>;
}
#[test]
fn test_add_bare() -> Result<()> {

View File

@ -9,6 +9,8 @@ mod serialize;
pub mod merkle;
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(test)]
mod tests;
@ -25,12 +27,12 @@ use serde::{Deserialize, Serialize};
use crate::{parameters::Network, transaction::Transaction, transparent};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
/// A Zcash block, containing a header and a list of transactions.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Block {
/// The block header, containing block metadata.
pub header: Header,

View File

@ -1,7 +1,7 @@
use crate::parameters::Network;
use crate::work::{difficulty::CompactDifficulty, equihash};
use super::super::*;
use super::*;
use chrono::{TimeZone, Utc};
use proptest::{

View File

@ -1,6 +1,6 @@
use std::{fmt, io};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
@ -19,7 +19,7 @@ use super::Header;
/// Note: Zebra displays transaction and block hashes in their actual byte-order,
/// not in reversed byte-order.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Hash(pub [u8; 32]);
impl fmt::Display for Hash {

View File

@ -79,9 +79,9 @@ impl Sub<i32> for Height {
}
}
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest::prelude::*;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
impl Arbitrary for Height {
type Parameters = ();

View File

@ -3,7 +3,7 @@
use std::{fmt, io};
#[cfg(test)]
#[cfg(any(any(test, feature = "proptest-impl"), feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use crate::serialization::{sha256d, SerializationError, ZcashDeserialize, ZcashSerialize};
@ -31,7 +31,7 @@ impl<Transaction> ZcashDeserialize for Tree<Transaction> {
/// A SHA-256d hash of the root node of a merkle tree of SHA256-d
/// hashed transactions in a block.
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Root(pub [u8; 32]);
impl From<Tree<Transaction>> for Root {

View File

@ -1,4 +1,3 @@
mod arbitrary;
// XXX this should be rewritten as strategies
mod generate;
mod prop;

View File

@ -1,9 +1,9 @@
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
/// An enum describing the possible network choices.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub enum Network {
/// The production mainnet.
Mainnet,

View File

@ -51,10 +51,10 @@ impl ZcashDeserialize for Bctv14Proof {
}
}
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
impl Arbitrary for Bctv14Proof {
type Parameters = ();

View File

@ -50,10 +50,10 @@ impl ZcashDeserialize for Groth16Proof {
}
}
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
impl Arbitrary for Groth16Proof {
type Parameters = ();

View File

@ -1,6 +1,8 @@
//! Sapling-related functionality.
mod address;
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
mod commitment;
mod note;
mod output;

View File

@ -2,7 +2,7 @@ use proptest::{arbitrary::any, array, collection::vec, prelude::*};
use crate::primitives::Groth16Proof;
use super::super::{commitment, keys, note, tree, Output, Spend};
use super::{commitment, keys, note, tree, Output, Spend};
impl Arbitrary for Spend {
type Parameters = ();

View File

@ -1,6 +1,6 @@
//! Note and value commitments.
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(test)]
mod test_vectors;

View File

@ -9,7 +9,7 @@
//! [3.1]: https://zips.z.cash/protocol/protocol.pdf#addressesandkeys
#![allow(clippy::unit_arg)]
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(test)]
mod test_vectors;
@ -26,7 +26,7 @@ use std::{
use bech32::{self, FromBase32, ToBase32};
use rand_core::{CryptoRng, RngCore};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use crate::{
@ -183,7 +183,7 @@ mod sk_hrp {
///
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct SpendingKey {
network: Network,
bytes: [u8; 32],
@ -610,7 +610,7 @@ impl PartialEq<[u8; 32]> for IncomingViewingKey {
///
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Diversifier(pub [u8; 11]);
impl fmt::Debug for Diversifier {

View File

@ -6,7 +6,7 @@
mod ciphertexts;
mod nullifiers;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
use crate::{

View File

@ -1,8 +1,5 @@
use std::{fmt, io};
#[cfg(test)]
use proptest::{arbitrary::any, prelude::*};
use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
/// A ciphertext component for encrypted output notes.
@ -103,6 +100,8 @@ impl ZcashDeserialize for WrappedNoteKey {
}
}
#[cfg(test)]
use proptest::prelude::*;
#[cfg(test)]
proptest! {

View File

@ -27,7 +27,10 @@ fn prf_nf(nk: [u8; 32], rho: [u8; 32]) -> [u8; 32] {
/// A Nullifier for Sapling transactions
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct Nullifier([u8; 32]);
impl From<[u8; 32]> for Nullifier {

View File

@ -1 +1 @@
mod arbitrary;

View File

@ -16,7 +16,7 @@
use std::{fmt, io};
use bitvec::prelude::*;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize};
@ -53,7 +53,7 @@ pub struct Position(pub(crate) u64);
/// Sapling Note Commitment Tree
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
struct SaplingNoteCommitmentTree;
/// Sapling note commitment tree root node hash.
@ -63,7 +63,7 @@ struct SaplingNoteCommitmentTree;
/// this block. A root of a note commitment tree is associated with
/// each treestate.
#[derive(Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Root(pub [u8; 32]);
impl fmt::Debug for Root {

View File

@ -1,8 +1,8 @@
//! Sprout-related functionality.
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
mod joinsplit;
#[cfg(test)]
mod tests;
// XXX clean up these modules

View File

@ -5,7 +5,7 @@ use crate::{
primitives::ZkSnarkProof,
};
use super::super::{commitment, note, tree, JoinSplit};
use super::{commitment, note, tree, JoinSplit};
impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
type Parameters = ();

View File

@ -8,7 +8,10 @@ use super::note::Note;
/// The randomness used in the Pedersen Hash for note commitment.
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct CommitmentRandomness(pub [u8; 32]);
impl AsRef<[u8]> for CommitmentRandomness {
@ -19,7 +22,10 @@ impl AsRef<[u8]> for CommitmentRandomness {
/// Note commitments for the output notes.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct NoteCommitment(pub(crate) [u8; 32]);
impl Eq for NoteCommitment {}

View File

@ -13,9 +13,9 @@ use byteorder::{ByteOrder, LittleEndian};
use rand_core::{CryptoRng, RngCore};
use sha2::digest::generic_array::{typenum::U64, GenericArray};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest::{array, prelude::*};
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use crate::{
@ -61,7 +61,7 @@ fn prf_addr(x: [u8; 32], t: u8) -> [u8; 32] {
/// All other Sprout key types derive from the SpendingKey value.
/// Actually 252 bits.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct SpendingKey {
/// What would normally be the value inside a tuple struct.
pub bytes: [u8; 32],
@ -183,7 +183,10 @@ impl From<SpendingKey> for ReceivingKey {
/// Derived from a _SpendingKey_.
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct PayingKey(pub [u8; 32]);
impl AsRef<[u8]> for PayingKey {
@ -310,7 +313,7 @@ impl std::str::FromStr for IncomingViewingKey {
}
}
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
impl Arbitrary for IncomingViewingKey {
type Parameters = ();

View File

@ -3,7 +3,7 @@
#![allow(clippy::unit_arg)]
#![allow(dead_code)]
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
mod ciphertexts;
mod mac;
@ -28,7 +28,10 @@ pub use nullifiers::{Nullifier, NullifierSeed};
///
/// https://zips.z.cash/protocol/protocol.pdf#notes
#[derive(Clone, Debug)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct Note {
/// The paying key of the recipients shielded payment address
pub paying_key: PayingKey,

View File

@ -1,8 +1,5 @@
use std::{fmt, io};
#[cfg(test)]
use proptest::{arbitrary::any, prelude::*};
use serde::{Deserialize, Serialize};
use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
@ -56,6 +53,8 @@ impl ZcashDeserialize for EncryptedNote {
}
}
#[cfg(test)]
use proptest::prelude::*;
#[cfg(test)]
proptest! {

View File

@ -6,7 +6,10 @@ use std::io::{self, Read};
/// binding h_sig to each a_sk of the JoinSplit description, computed as
/// described in § 4.10 Non-malleability (Sprout) on p. 37
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct MAC([u8; 32]);
impl ZcashDeserialize for MAC {

View File

@ -37,7 +37,10 @@ fn prf_nf(a_sk: [u8; 32], rho: [u8; 32]) -> [u8; 32] {
/// [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
#[derive(Clone, Copy, Debug)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct NullifierSeed(pub(crate) [u8; 32]);
impl AsRef<[u8]> for NullifierSeed {
@ -60,7 +63,10 @@ impl From<NullifierSeed> for [u8; 32] {
/// A Nullifier for Sprout transactions
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct Nullifier(pub(crate) [u8; 32]);
impl From<[u8; 32]> for Nullifier {

View File

@ -13,7 +13,7 @@
use std::fmt;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
/// Sprout note commitment tree root node hash.
@ -23,7 +23,7 @@ use proptest_derive::Arbitrary;
/// this block. A root of a note commitment tree is associated with
/// each treestate.
#[derive(Clone, Copy, Default, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Root([u8; 32]);
impl fmt::Debug for Root {

View File

@ -10,6 +10,8 @@ mod serialize;
mod shielded_data;
mod sighash;
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(test)]
mod tests;

View File

@ -9,9 +9,10 @@ use crate::{
sapling, sprout, transparent,
};
use super::super::{JoinSplitData, LockTime, Memo, ShieldedData, Transaction};
use super::{JoinSplitData, LockTime, Memo, ShieldedData, Transaction};
impl Transaction {
/// Generate a proptest strategy for V1 Transactions
pub fn v1_strategy() -> impl Strategy<Value = Self> {
(
vec(any::<transparent::Input>(), 0..10),
@ -26,6 +27,7 @@ impl Transaction {
.boxed()
}
/// Generate a proptest strategy for V2 Transactions
pub fn v2_strategy() -> impl Strategy<Value = Self> {
(
vec(any::<transparent::Input>(), 0..10),
@ -44,6 +46,7 @@ impl Transaction {
.boxed()
}
/// Generate a proptest strategy for V3 Transactions
pub fn v3_strategy() -> impl Strategy<Value = Self> {
(
vec(any::<transparent::Input>(), 0..10),
@ -64,6 +67,7 @@ impl Transaction {
.boxed()
}
/// Generate a proptest strategy for V4 Transactions
pub fn v4_strategy() -> impl Strategy<Value = Self> {
(
vec(any::<transparent::Input>(), 0..10),

View File

@ -1,7 +1,7 @@
#![allow(clippy::unit_arg)]
use std::fmt;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
@ -14,7 +14,7 @@ use super::Transaction;
/// Note: Zebra displays transaction and block hashes in their actual byte-order,
/// not in reversed byte-order.
#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Hash(pub [u8; 32]);
impl<'a> From<&'a Transaction> for Hash {

View File

@ -1,3 +1,2 @@
mod arbitrary;
mod prop;
mod vectors;

View File

@ -9,9 +9,9 @@ mod serialize;
pub use address::Address;
pub use script::Script;
#[cfg(test)]
mod tests;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
use crate::{
@ -41,7 +41,7 @@ impl AsRef<[u8]> for CoinbaseData {
///
/// A particular transaction output reference.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct OutPoint {
/// References the transaction that contains the UTXO being spent.
pub hash: transaction::Hash,
@ -87,7 +87,7 @@ pub enum Input {
/// that spends my UTXO and sends 1 ZEC to you and 1 ZEC back to me
/// (just like receiving change).
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct Output {
/// Transaction value.
// At https://en.bitcoin.it/wiki/Protocol_documentation#tx, this is an i64.

View File

@ -2,7 +2,7 @@ use proptest::{arbitrary::any, collection::vec, prelude::*};
use crate::block;
use super::super::{CoinbaseData, Input, OutPoint, Script};
use super::{CoinbaseData, Input, OutPoint, Script};
impl Arbitrary for Input {
type Parameters = ();

View File

@ -9,7 +9,10 @@ use std::{
/// An encoding of a Bitcoin script.
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
#[cfg_attr(
any(test, feature = "proptest-impl"),
derive(proptest_derive::Arbitrary)
)]
pub struct Script(pub Vec<u8>);
impl fmt::Debug for Script {

View File

@ -1 +0,0 @@
mod arbitrary;

View File

@ -3,5 +3,7 @@
pub mod difficulty;
pub mod equihash;
#[cfg(any(test, feature = "proptest-impl"))]
mod arbitrary;
#[cfg(test)]
mod tests;

View File

@ -1,4 +1,4 @@
use super::super::*;
use super::*;
use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*};

View File

@ -18,9 +18,9 @@ use std::{fmt, ops::Add, ops::AddAssign};
use primitive_types::U256;
#[cfg(test)]
#[cfg(any(test, feature = "proptest-impl"))]
use proptest_derive::Arbitrary;
#[cfg(test)]
#[cfg(tests)]
mod tests;
/// A 32-bit "compact bits" value, which represents the difficulty threshold for
@ -52,7 +52,7 @@ mod tests;
/// multiple equivalent `CompactDifficulty` values, due to redundancy in the
/// floating-point format.
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Arbitrary))]
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
pub struct CompactDifficulty(pub u32);
impl fmt::Debug for CompactDifficulty {

View File

@ -1,3 +1,2 @@
mod arbitrary;
mod prop;
mod vectors;

View File

@ -26,6 +26,7 @@ thiserror = "1.0.20"
tokio = { version = "0.2.22", features = ["sync"] }
[dev-dependencies]
zebra-chain = { path = "../zebra-chain", features = ["proptest-impl"] }
zebra-test = { path = "../zebra-test/" }
once_cell = "1.4"

View File

@ -21,6 +21,7 @@ regex = "1.3.9"
thiserror = "1.0.20"
pretty_assertions = "0.6.1"
owo-colors = "1.1.3"
proptest = "0.10.1"
[dev-dependencies]
tokio = { version = "0.2", features = ["full"] }

View File

@ -5,3 +5,4 @@ pub use color_eyre;
pub use color_eyre::eyre;
pub use eyre::Result;
pub use pretty_assertions::{assert_eq, assert_ne};
pub use proptest::prelude::*;