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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::{
account_address::AccountAddress,
identifier::Identifier,
language_storage::{StructTag, TypeTag},
transaction_argument::TransactionArgument,
};
use proptest::{collection::vec, prelude::*};
impl Arbitrary for TypeTag {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
use TypeTag::*;
let leaf = prop_oneof![
Just(Bool),
Just(U8),
Just(U64),
Just(U128),
Just(Address),
Just(Vector(Box::new(Bool))),
];
leaf.prop_recursive(
8, 16, 4, |inner| {
(
any::<AccountAddress>(),
any::<Identifier>(),
any::<Identifier>(),
vec(inner, 0..4),
)
.prop_map(|(address, module, name, type_params)| {
Struct(StructTag {
address,
module,
name,
type_params,
})
})
},
)
.boxed()
}
}
impl Arbitrary for TransactionArgument {
type Parameters = ();
fn arbitrary_with(_args: ()) -> Self::Strategy {
prop_oneof![
any::<bool>().prop_map(TransactionArgument::Bool),
any::<u64>().prop_map(TransactionArgument::U64),
any::<AccountAddress>().prop_map(TransactionArgument::Address),
vec(any::<u8>(), 0..10).prop_map(TransactionArgument::U8Vector),
]
.boxed()
}
type Strategy = BoxedStrategy<Self>;
}