From a259a6b4b1444b2a7749b8fd380115fe3ed6426e Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Mon, 27 Jan 2020 23:26:01 -0500 Subject: [PATCH] Add and use v4_strategy() --- zebra-chain/src/transaction/tests.rs | 44 ++++++++++++++++++++++++---- zebra-chain/src/types.rs | 3 +- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/zebra-chain/src/transaction/tests.rs b/zebra-chain/src/transaction/tests.rs index 72d3ca024..2db65d475 100644 --- a/zebra-chain/src/transaction/tests.rs +++ b/zebra-chain/src/transaction/tests.rs @@ -1,7 +1,3 @@ -use std::io::Cursor; - -use chrono::{TimeZone, Utc}; - use proptest::{ arbitrary::{any, Arbitrary}, collection::vec, @@ -69,6 +65,38 @@ impl Transaction { ) .boxed() } + + pub fn v4_strategy() -> impl Strategy { + ( + vec(any::(), 0..10), + vec(any::(), 0..10), + any::(), + any::(), + any::(), + option::of(any::()), + option::of(any::>()), + ) + .prop_map( + |( + inputs, + outputs, + lock_time, + expiry_height, + value_balance, + shielded_data, + joinsplit_data, + )| Transaction::V4 { + inputs: inputs, + outputs: outputs, + lock_time: lock_time, + expiry_height: expiry_height, + value_balance: value_balance, + shielded_data: shielded_data, + joinsplit_data: joinsplit_data, + }, + ) + .boxed() + } } #[cfg(test)] @@ -76,7 +104,13 @@ impl Arbitrary for Transaction { type Parameters = (); fn arbitrary_with(_args: ()) -> Self::Strategy { - prop_oneof![Self::v1_strategy(), Self::v2_strategy(), Self::v3_strategy()].boxed() + prop_oneof![ + Self::v1_strategy(), + Self::v2_strategy(), + Self::v3_strategy(), + Self::v4_strategy() + ] + .boxed() } type Strategy = BoxedStrategy; diff --git a/zebra-chain/src/types.rs b/zebra-chain/src/types.rs index 3b24d4983..f2430a9bb 100644 --- a/zebra-chain/src/types.rs +++ b/zebra-chain/src/types.rs @@ -154,9 +154,8 @@ mod proptests { use std::io::Cursor; use proptest::prelude::*; - use proptest_derive::Arbitrary; - use super::{BlockHeight, LockTime, Script}; + use super::{LockTime, Script}; use crate::serialization::{ZcashDeserialize, ZcashSerialize}; proptest! {