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            any::<Amount<NegativeAllowed>>(),
16        )
17            .prop_map(
18                |(transparent, sprout, sapling, orchard, deferred, ironwood, nsm)| Self {
19                    transparent,
20                    sprout,
21                    sapling,
22                    orchard,
23                    deferred,
24                    ironwood,
25                    nsm,
26                },
27            )
28            .boxed()
29    }
30
31    type Strategy = BoxedStrategy<Self>;
32}
33
34impl Arbitrary for ValueBalance<NonNegative> {
35    type Parameters = ();
36
37    fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
38        (
39            any::<Amount<NonNegative>>(),
40            any::<Amount<NonNegative>>(),
41            any::<Amount<NonNegative>>(),
42            any::<Amount<NonNegative>>(),
43            any::<Amount<NonNegative>>(),
44            any::<Amount<NonNegative>>(),
45            any::<Amount<NonNegative>>(),
46        )
47            .prop_map(
48                |(transparent, sprout, sapling, orchard, deferred, ironwood, nsm)| Self {
49                    transparent,
50                    sprout,
51                    sapling,
52                    orchard,
53                    deferred,
54                    ironwood,
55                    nsm,
56                },
57            )
58            .boxed()
59    }
60
61    type Strategy = BoxedStrategy<Self>;
62}