Skip to content

Commit bc6d4a9

Browse files
committed
wip
1 parent 3f6160d commit bc6d4a9

File tree

2 files changed

+48
-42
lines changed

2 files changed

+48
-42
lines changed

rust/catalyst-voting/src/txs/v1/decoding.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -143,51 +143,9 @@ impl Tx {
143143

144144
#[cfg(test)]
145145
mod tests {
146-
use proptest::prelude::{any, any_with, Arbitrary, BoxedStrategy, Strategy};
147146
use test_strategy::proptest;
148147

149148
use super::*;
150-
use crate::SecretKey;
151-
152-
impl Arbitrary for Tx {
153-
type Parameters = ();
154-
type Strategy = BoxedStrategy<Self>;
155-
156-
fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
157-
any::<([u8; 32], u8, Vote, SecretKey)>()
158-
.prop_map(|(vote_plan_id, proposal_index, vote, s)| {
159-
Tx {
160-
vote_plan_id,
161-
proposal_index,
162-
vote,
163-
public_key: s.public_key(),
164-
}
165-
})
166-
.boxed()
167-
}
168-
}
169-
170-
impl Arbitrary for Vote {
171-
type Parameters = ();
172-
type Strategy = BoxedStrategy<Self>;
173-
174-
fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
175-
any::<bool>()
176-
.prop_flat_map(|b| {
177-
if b {
178-
any::<u8>().prop_map(Vote::Public).boxed()
179-
} else {
180-
any::<(u8, u8)>()
181-
.prop_flat_map(|(s1, s2)| {
182-
any_with::<(EncryptedVote, VoterProof)>((s1.into(), s2.into()))
183-
.prop_map(|(v, p)| Vote::Private(v, p))
184-
})
185-
.boxed()
186-
}
187-
})
188-
.boxed()
189-
}
190-
}
191149

192150
#[proptest]
193151
#[allow(clippy::indexing_slicing)]

rust/catalyst-voting/src/txs/v1/mod.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,51 @@ pub enum Vote {
3030
/// Private (encrypted) voting choice
3131
Private(EncryptedVote, VoterProof),
3232
}
33+
34+
#[cfg(test)]
35+
mod tests {
36+
use proptest::prelude::{any, any_with, Arbitrary, BoxedStrategy, Strategy};
37+
38+
use super::*;
39+
use crate::SecretKey;
40+
41+
impl Arbitrary for Tx {
42+
type Parameters = ();
43+
type Strategy = BoxedStrategy<Self>;
44+
45+
fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
46+
any::<([u8; 32], u8, Vote, SecretKey)>()
47+
.prop_map(|(vote_plan_id, proposal_index, vote, s)| {
48+
Tx {
49+
vote_plan_id,
50+
proposal_index,
51+
vote,
52+
public_key: s.public_key(),
53+
}
54+
})
55+
.boxed()
56+
}
57+
}
58+
59+
impl Arbitrary for Vote {
60+
type Parameters = ();
61+
type Strategy = BoxedStrategy<Self>;
62+
63+
fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
64+
any::<bool>()
65+
.prop_flat_map(|b| {
66+
if b {
67+
any::<u8>().prop_map(Vote::Public).boxed()
68+
} else {
69+
any::<(u8, u8)>()
70+
.prop_flat_map(|(s1, s2)| {
71+
any_with::<(EncryptedVote, VoterProof)>((s1.into(), s2.into()))
72+
.prop_map(|(v, p)| Vote::Private(v, p))
73+
})
74+
.boxed()
75+
}
76+
})
77+
.boxed()
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)