zebra_chain/parameters/
arbitrary.rs

1//! Arbitrary implementations for network parameters
2
3use proptest::prelude::*;
4
5use super::{Network, NetworkUpgrade};
6
7impl NetworkUpgrade {
8    /// Generates network upgrades.
9    pub fn branch_id_strategy() -> BoxedStrategy<NetworkUpgrade> {
10        prop_oneof![
11            Just(NetworkUpgrade::Overwinter),
12            Just(NetworkUpgrade::Sapling),
13            Just(NetworkUpgrade::Blossom),
14            Just(NetworkUpgrade::Heartwood),
15            Just(NetworkUpgrade::Canopy),
16            Just(NetworkUpgrade::Nu5),
17            // TODO: add future network upgrades (#1974)
18        ]
19        .boxed()
20    }
21
22    /// Generates network upgrades from a reduced set
23    pub fn reduced_branch_id_strategy() -> BoxedStrategy<NetworkUpgrade> {
24        // We use this strategy to test legacy chain
25        // TODO: We can add Canopy after we have a NU5 activation height
26        prop_oneof![
27            Just(NetworkUpgrade::Overwinter),
28            Just(NetworkUpgrade::Sapling),
29            Just(NetworkUpgrade::Blossom),
30            Just(NetworkUpgrade::Heartwood),
31        ]
32        .boxed()
33    }
34}
35
36impl Arbitrary for Network {
37    type Parameters = ();
38
39    fn arbitrary_with(_args: ()) -> Self::Strategy {
40        prop_oneof![Just(Self::Mainnet), Just(Self::new_default_testnet())].boxed()
41    }
42
43    type Strategy = BoxedStrategy<Self>;
44}