Skip to main content

zebra_chain/value_balance/
arbitrary.rs

1use crate::{amount::*, value_balance::*};
2use proptest::prelude::*;
3
4impl Arbitrary for ValueBalance<NegativeAllowed> {
5    type Parameters = ();
6
7    fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
8        (
9            any::<Amount<NegativeAllowed>>(),
10            any::<Amount<NegativeAllowed>>(),
11            any::<Amount<NegativeAllowed>>(),
12            any::<Amount<NegativeAllowed>>(),
13            any::<Amount<NegativeAllowed>>(),
14            any::<Amount<NegativeAllowed>>(),
15        )
16            .prop_map(
17                |(transparent, sprout, sapling, orchard, deferred, ironwood)| Self {
18                    transparent,
19                    sprout,
20                    sapling,
21                    orchard,
22                    deferred,
23                    ironwood,
24                },
25            )
26            .boxed()
27    }
28
29    type Strategy = BoxedStrategy<Self>;
30}
31
32impl Arbitrary for ValueBalance<NonNegative> {
33    type Parameters = ();
34
35    fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
36        (
37            any::<Amount<NonNegative>>(),
38            any::<Amount<NonNegative>>(),
39            any::<Amount<NonNegative>>(),
40            any::<Amount<NonNegative>>(),
41            any::<Amount<NonNegative>>(),
42            any::<Amount<NonNegative>>(),
43        )
44            .prop_map(
45                |(transparent, sprout, sapling, orchard, deferred, ironwood)| Self {
46                    transparent,
47                    sprout,
48                    sapling,
49                    orchard,
50                    deferred,
51                    ironwood,
52                },
53            )
54            .boxed()
55    }
56
57    type Strategy = BoxedStrategy<Self>;
58}