1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use chain_addr::{Kind, KindType};
use quickcheck::{Arbitrary, Gen};
use std::iter;

#[derive(Clone, Debug)]
pub struct KindTypeWithoutMultisig(pub KindType);

impl Arbitrary for KindTypeWithoutMultisig {
    fn arbitrary<G: Gen>(g: &mut G) -> Self {
        KindTypeWithoutMultisig(
            iter::from_fn(|| Some(KindType::arbitrary(g)))
                .find(|x| !matches!(x, KindType::Multisig | KindType::Script))
                .unwrap(),
        )
    }
}

impl KindTypeWithoutMultisig {
    pub fn kind_type(&self) -> KindType {
        self.0
    }
}

impl From<KindTypeWithoutMultisig> for KindType {
    fn from(kind_type_without_multisig: KindTypeWithoutMultisig) -> Self {
        kind_type_without_multisig.kind_type()
    }
}

#[derive(Clone, Debug)]
pub struct KindWithoutMultisig(pub Kind);

impl Arbitrary for KindWithoutMultisig {
    fn arbitrary<G: Gen>(g: &mut G) -> Self {
        KindWithoutMultisig(
            iter::from_fn(|| Some(Kind::arbitrary(g)))
                .find(|x| !matches!(x, Kind::Multisig { .. }))
                .unwrap(),
        )
    }
}