Skip to content

Commit 779dd52

Browse files
committed
refactor proptest::Arbitrary impl
1 parent 7c70da0 commit 779dd52

File tree

10 files changed

+26
-9
lines changed

10 files changed

+26
-9
lines changed

rust/catalyst-voting/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
2424
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
2525
blake2b_simd = "1.0.2"
2626
rayon = "1.10.0"
27+
proptest = { version = "1.5.0", optional = true }
2728

2829
[dev-dependencies]
2930
criterion = "0.5.1"
@@ -35,4 +36,4 @@ test-strategy = "0.4.0"
3536
[features]
3637
# Feature which makes publicly available
3738
# `proptest::prelude::Arbitrary` trait implementation for some types
38-
proptest-arbitrary = []
39+
proptest-arbitrary = ["dep:proptest"]

rust/catalyst-voting/src/crypto/ed25519/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ pub fn verify_signature(pk: &PublicKey, msg: &[u8], sig: &Signature) -> bool {
4747
}
4848

4949
#[cfg(any(test, feature = "proptest-arbitrary"))]
50+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
5051
mod arbitrary_impl {
5152
use proptest::prelude::{any, Arbitrary, BoxedStrategy, Strategy};
5253

53-
use super::*;
54+
use super::{PrivateKey, SigningKey};
5455

5556
impl Arbitrary for PrivateKey {
5657
type Parameters = ();

rust/catalyst-voting/src/crypto/elgamal/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ impl Add<&Ciphertext> for &Ciphertext {
6767
}
6868

6969
#[cfg(any(test, feature = "proptest-arbitrary"))]
70+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
7071
mod arbitrary_impl {
7172
use proptest::{
7273
arbitrary::any,
7374
prelude::{Arbitrary, BoxedStrategy, Strategy},
7475
};
7576

76-
use super::*;
77+
use super::{Ciphertext, GroupElement};
7778

7879
impl Arbitrary for Ciphertext {
7980
type Parameters = ();

rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ impl Sub<&GroupElement> for &GroupElement {
160160
}
161161

162162
#[cfg(any(test, feature = "proptest-arbitrary"))]
163+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
163164
mod arbitrary_impl {
164165
use proptest::{
165166
arbitrary::any,
166167
prelude::{Arbitrary, BoxedStrategy, Strategy},
167168
};
168169

169-
use super::*;
170+
use super::{GroupElement, Mul, Scalar};
170171

171172
impl Arbitrary for Scalar {
172173
type Parameters = ();

rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,14 @@ fn check_2(
236236
}
237237

238238
#[cfg(any(test, feature = "proptest-arbitrary"))]
239+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
239240
mod arbitrary_impl {
240241
use proptest::{
241242
prelude::{any_with, Arbitrary, BoxedStrategy, Strategy},
242243
sample::size_range,
243244
};
244245

245-
use super::*;
246+
use super::{Announcement, Ciphertext, ResponseRandomness, Scalar, UnitVectorProof};
246247

247248
impl Arbitrary for UnitVectorProof {
248249
type Parameters = usize;

rust/catalyst-voting/src/crypto/zk_unit_vector/randomness_announcements.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ impl ResponseRandomness {
8080
}
8181

8282
#[cfg(any(test, feature = "proptest-arbitrary"))]
83+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
8384
mod arbitrary_impl {
8485
use proptest::{
8586
arbitrary::any,
8687
prelude::{Arbitrary, BoxedStrategy, Strategy},
8788
};
8889

89-
use super::*;
90+
use super::{Announcement, BlindingRandomness, GroupElement, ResponseRandomness, Scalar};
9091

9192
impl Arbitrary for BlindingRandomness {
9293
type Parameters = ();

rust/catalyst-voting/src/vote_protocol/committee/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ impl ElectionSecretKey {
3737
pub struct ElectionPublicKey(pub(crate) GroupElement);
3838

3939
#[cfg(any(test, feature = "proptest-arbitrary"))]
40+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
4041
mod arbitrary_impl {
4142
use proptest::prelude::{any, Arbitrary, BoxedStrategy, Strategy};
4243

43-
use super::*;
44+
use super::{ElectionSecretKey, Scalar};
4445

4546
impl Arbitrary for ElectionSecretKey {
4647
type Parameters = ();

rust/catalyst-voting/src/vote_protocol/voter/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ pub fn decrypt_vote(vote: &EncryptedVote, secret_key: &ElectionSecretKey) -> any
142142
}
143143

144144
#[cfg(any(test, feature = "proptest-arbitrary"))]
145+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
145146
mod arbitrary_impl {
146147
use proptest::{
147148
prelude::{any_with, Arbitrary, BoxedStrategy, Strategy},
148149
sample::size_range,
149150
};
150151

151-
use super::*;
152+
use super::{Ciphertext, EncryptedVote};
152153

153154
impl Arbitrary for EncryptedVote {
154155
type Parameters = usize;

rust/catalyst-voting/src/vote_protocol/voter/proof.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ pub fn verify_voter_proof(
108108
}
109109

110110
#[cfg(any(test, feature = "proptest-arbitrary"))]
111+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
111112
mod arbitrary_impl {
112113
use proptest::prelude::{any_with, Arbitrary, BoxedStrategy, Strategy};
113114

114-
use super::*;
115+
use super::{UnitVectorProof, VoterProof};
115116

116117
impl Arbitrary for VoterProof {
117118
type Parameters = usize;

rust/jormungandr-vote-tx/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ workspace = true
1414
catalyst-voting = { path = "../catalyst-voting" }
1515
anyhow = "1.0.89"
1616

17+
[dev-dependencies]
18+
catalyst-voting = { path = "../catalyst-voting", features = ["proptest-arbitrary"] }
19+
1720
proptest = { version = "1.5.0" }
1821
# Potentially it could be replaced with using `proptest::property_test` attribute macro,
1922
# after this PR will be merged https://github.com/proptest-rs/proptest/pull/523
2023
test-strategy = "0.4.0"
24+
25+
[features]
26+
# Feature which makes publicly available
27+
# `proptest::prelude::Arbitrary` trait implementation for some types
28+
proptest-arbitrary = ["catalyst-voting/proptest-arbitrary"]

0 commit comments

Comments
 (0)