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
64
65
66
67
68
69
70
use crate::sigma_protocol::dlog_group;
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct PreHeader {
pub version: u8,
pub parent_id: Vec<u8>,
pub timestamp: u64,
pub n_bits: u64,
pub height: u32,
pub miner_pk: Box<dlog_group::EcPoint>,
pub votes: Vec<u8>,
}
impl PreHeader {
pub fn dummy() -> Self {
PreHeader {
version: 1,
parent_id: vec![0; 32],
timestamp: 0,
n_bits: 0,
height: 0,
miner_pk: dlog_group::generator().into(),
votes: Vec::new(),
}
}
}
#[cfg(feature = "arbitrary")]
mod arbitrary {
use crate::mir::header::PreHeader;
use crate::sigma_protocol::dlog_group::EcPoint;
use proptest::collection::vec;
use proptest::prelude::*;
impl Arbitrary for PreHeader {
type Parameters = ();
type Strategy = BoxedStrategy<PreHeader>;
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
(
vec(any::<u8>(), 32),
946_674_000_000..2_500_400_300_000u64,
any::<u64>(),
0..1_000_000u32,
any::<Box<EcPoint>>(),
)
.prop_map(|(parent_id, timestamp, n_bits, height, miner_pk)| Self {
version: 1,
parent_id,
timestamp,
n_bits,
height,
miner_pk,
votes: Vec::new(),
})
.boxed()
}
}
}