diff --git a/src/ietf.rs b/src/ietf.rs index e270f13..83dadd2 100644 --- a/src/ietf.rs +++ b/src/ietf.rs @@ -149,6 +149,16 @@ pub mod testing { assert!(result.is_ok()); } + #[macro_export] + macro_rules! ietf_suite_tests { + ($suite:ident) => { + #[test] + fn ietf_prove_verify() { + $crate::ietf::testing::prove_verify::<$suite>(); + } + }; + } + pub struct TestVector { pub base: common::TestVector, pub c: ScalarField, diff --git a/src/pedersen.rs b/src/pedersen.rs index 64def68..6bdcab5 100644 --- a/src/pedersen.rs +++ b/src/pedersen.rs @@ -146,7 +146,7 @@ pub(crate) mod testing { use super::*; use crate::testing::{self as common, random_val, TEST_SEED}; - pub fn pedersen_prove_verify() { + pub fn prove_verify() { use pedersen::{Prover, Verifier}; let secret = Secret::::from_seed(TEST_SEED); @@ -163,6 +163,16 @@ pub(crate) mod testing { ); } + #[macro_export] + macro_rules! pedersen_suite_tests { + ($suite:ident) => { + #[test] + fn pedersen_prove_verify() { + $crate::pedersen::testing::prove_verify::<$suite>(); + } + }; + } + pub struct TestVector { pub base: common::TestVector, pub blind: ScalarField, diff --git a/src/ring.rs b/src/ring.rs index 2046ed0..8a993ff 100644 --- a/src/ring.rs +++ b/src/ring.rs @@ -307,18 +307,16 @@ where } #[cfg(test)] -pub(crate) mod test { +pub(crate) mod testing { use super::*; use crate::testing::*; - pub fn ring_prove_verify() + pub fn prove_verify() where BaseField: ark_ff::PrimeField, CurveConfig: ark_ec::short_weierstrass::SWCurveConfig + Clone, AffinePoint: utils::te_sw_map::SWMapping>, { - use ring::{Prover, RingContext, Verifier}; - let rng = &mut ark_std::test_rng(); let ring_ctx = RingContext::::from_rand(512, rng); @@ -343,7 +341,7 @@ pub(crate) mod test { assert!(result.is_ok()); } - pub fn check_complement_point() + pub fn check_complement_point() where BaseField: ark_ff::PrimeField, CurveConfig: ark_ec::short_weierstrass::SWCurveConfig + Clone, @@ -361,13 +359,13 @@ pub(crate) mod test { #[cfg(feature = "ring")] #[test] fn ring_prove_verify() { - $crate::ring::test::ring_prove_verify::<$suite>() + $crate::ring::testing::prove_verify::<$suite>() } #[cfg(feature = "ring")] #[test] fn check_complement_point() { - $crate::ring::test::check_complement_point::<$suite>() + $crate::ring::testing::check_complement_point::<$suite>() } }; ($suite:ident, false) => {}; diff --git a/src/testing.rs b/src/testing.rs index 664d784..19f5863 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -28,15 +28,8 @@ macro_rules! suite_tests { ring_suite_tests!($suite, $build_ring); }; ($suite:ident) => { - #[test] - fn ietf_prove_verify() { - $crate::ietf::testing::prove_verify::<$suite>(); - } - - #[test] - fn pedersen_prove_verify() { - $crate::pedersen::testing::pedersen_prove_verify::<$suite>(); - } + ietf_suite_tests!($suite); + pedersen_suite_tests!($suite); }; }