Skip to content

Commit

Permalink
Update macro syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Varlakov <[email protected]>
  • Loading branch information
survived committed Dec 6, 2024
1 parent 582d92e commit 6026e03
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 53 deletions.
29 changes: 17 additions & 12 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,18 @@ macro_rules! test_suite {
$crate::test_suite! {
$(async_test = $async_test,)?
$(test = $test,)?
generics = [
secp256k1 = <cggmp21::supported_curves::Secp256k1>,
secp256r1 = <cggmp21::supported_curves::Secp256r1>,
stark = <cggmp21::supported_curves::Stark>,
],
generics = {
secp256k1: <cggmp21::supported_curves::Secp256k1>,
secp256r1: <cggmp21::supported_curves::Secp256r1>,
stark: <cggmp21::supported_curves::Stark>,
},
suites = [$($suites)*]
}
};
(
$(async_test = $async_test:ident,)?
$(test = $test:ident,)?
generics = [$($gmod:ident = <$($generic:path),*>),+$(,)?],
generics = {$($gmod:ident: <$($generic:path),*>),+$(,)?},
suites = [$($suites:tt)*]
$(,)?
) => {
Expand All @@ -233,7 +233,7 @@ macro_rules! test_suite {
$crate::test_suite_traverse! {
$(async_test = $async_test,)?
$(test = $test,)?
generics = [$($gmod = <$($generic),+>),+],
generics = {$($gmod: <$($generic),+>),+},
suites = [$($suites)*]
}
}
Expand All @@ -248,7 +248,10 @@ macro_rules! test_suite_traverse {
$(async_test = $async_test:ident,)?
$(test = $test:ident,)?
// we traverse over `generics`
generics = [$gmod:ident = <$($generic:path),*>$(, $($generics_rest:tt)*)?],
generics = {
$gmod:ident: <$($generic:path),*>
$(, $($generics_rest:tt)*)?
},
suites = [$($suites:tt)*]
) => {
mod $gmod {
Expand All @@ -263,15 +266,17 @@ macro_rules! test_suite_traverse {
$crate::test_suite_traverse! {
$(async_test = $async_test,)?
$(test = $test,)?
generics = [$($($generics_rest)*)?],
generics = {
$($($generics_rest)*)?
},
suites = [$($suites)*]
}
};
(
$(async_test = $async_test:ident,)?
$(test = $test:ident,)?
// generics list is empty - nothing to traverse
generics = [],
generics = {},
suites = [$($suites:tt)*]
) => {};

Expand All @@ -281,7 +286,7 @@ macro_rules! test_suite_traverse {
// we traverse async suites
suites = [
$(#[$attr:meta])*
$suite_name:ident($($args:tt)*)
$suite_name:ident: ($($args:tt)*)
$(, $($rest:tt)*)?
]
) => {
Expand All @@ -303,7 +308,7 @@ macro_rules! test_suite_traverse {
// we traverse sync suites
suites = [
$(#[$attr:meta])*
$suite_name:ident($($args:tt)*)
$suite_name:ident: ($($args:tt)*)
$(, $($rest:tt)*)?
]
) => {
Expand Down
12 changes: 6 additions & 6 deletions tests/tests/it/key_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ cggmp21_tests::test_suite! {
test = key_refresh_works,
generics = all_curves,
suites = [
n3(3, false),
n5(5, false),
n5_reliable(5, true),
n3: (3, false),
n5: (5, false),
n5_reliable: (5, true),
]
}
fn key_refresh_works<E: generic_ec::Curve>(n: u16, reliable_broadcast: bool)
Expand Down Expand Up @@ -114,9 +114,9 @@ cggmp21_tests::test_suite! {
test = aux_gen_works,
generics = all_curves,
suites = [
t2n3(2, 3, false),
t3n5(3, 5, false),
t3n5_reliable(3, 5, true),
t2n3: (2, 3, false),
t3n5: (3, 5, false),
t3n5_reliable: (3, 5, true),
]
}
fn aux_gen_works<E: generic_ec::Curve>(t: u16, n: u16, reliable_broadcast: bool)
Expand Down
32 changes: 16 additions & 16 deletions tests/tests/it/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ cggmp21_tests::test_suite! {
test = keygen_works,
generics = all_curves,
suites = [
n3(3, false, false),
n5(5, false, false),
n7(7, false, false),
n10(10, false, false),
n10_reliable(10, true, false),
n3: (3, false, false),
n5: (5, false, false),
n7: (7, false, false),
n10: (10, false, false),
n10_reliable: (10, true, false),
#[cfg(feature = "hd-wallet")]
n3_hd(3, false, true),
n3_hd: (3, false, true),
#[cfg(feature = "hd-wallet")]
n5_hd(5, false, true),
n5_hd: (5, false, true),
#[cfg(feature = "hd-wallet")]
n7_hd(7, false, true),
n7_hd: (7, false, true),
#[cfg(feature = "hd-wallet")]
n10_hd(10, false, true),
n10_hd: (10, false, true),
]
}
fn keygen_works<E: Curve>(n: u16, reliable_broadcast: bool, hd_wallet: bool) {
Expand Down Expand Up @@ -58,13 +58,13 @@ cggmp21_tests::test_suite! {
test = threshold_keygen_works,
generics = all_curves,
suites = [
t2n3(2, 3, false, false),
t3n5(3, 5, false, false),
t3n5_reliable(3, 5, true, false),
t2n3: (2, 3, false, false),
t3n5: (3, 5, false, false),
t3n5_reliable: (3, 5, true, false),
#[cfg(feature = "hd-wallet")]
t2n3_hd(2, 3, false, true),
t2n3_hd: (2, 3, false, true),
#[cfg(feature = "hd-wallet")]
t3n5_hd(3, 5, false, true),
t3n5_hd: (3, 5, false, true),
]
}
fn threshold_keygen_works<E: Curve>(t: u16, n: u16, reliable_broadcast: bool, hd_wallet: bool) {
Expand Down Expand Up @@ -101,9 +101,9 @@ cggmp21_tests::test_suite! {
test = threshold_keygen_sync_works,
generics = all_curves,
suites = [
t3n5(3, 5, false),
t3n5: (3, 5, false),
#[cfg(feature = "hd-wallet")]
t3n5_hd(3, 5, true),
t3n5_hd: (3, 5, true),
]
}
fn threshold_keygen_sync_works<E: Curve>(t: u16, n: u16, hd_wallet: bool) {
Expand Down
6 changes: 3 additions & 3 deletions tests/tests/it/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ cggmp21_tests::test_suite! {
test = full_pipeline_works,
generics = all_curves,
suites = [
t2n3(2, 3, false),
t3n5(3, 5, false),
t2n3: (2, 3, false),
t3n5: (3, 5, false),
#[cfg(feature = "hd-wallet")]
t3n5_hd(3, 5, true),
t3n5_hd: (3, 5, true),
]
}
fn full_pipeline_works<E>(t: u16, n: u16, hd_enabled: bool)
Expand Down
30 changes: 15 additions & 15 deletions tests/tests/it/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ cggmp21_tests::test_suite! {
test = signing_works,
generics = all_curves,
suites = [
n2(None, 2, false, false),
n2_reliable(None, 2, true, false),
t2n2(Some(2), 2, false, false),
n3(None, 3, false, false),
t2n3(Some(2), 3, false, false),
t3n3(Some(3), 3, false, false),
n2: (None, 2, false, false),
n2_reliable: (None, 2, true, false),
t2n2: (Some(2), 2, false, false),
n3: (None, 3, false, false),
t2n3: (Some(2), 3, false, false),
t3n3: (Some(3), 3, false, false),

#[cfg(feature = "hd-wallet")]
n3_hd(None, 3, false, true),
n3_hd: (None, 3, false, true),
#[cfg(feature = "hd-wallet")]
t2n3_hd(Some(2), 3, false, true),
t2n3_hd: (Some(2), 3, false, true),
#[cfg(feature = "hd-wallet")]
t3n3_hd(Some(3), 3, false, true),
t3n3_hd: (Some(3), 3, false, true),
]
}

Expand Down Expand Up @@ -114,9 +114,9 @@ cggmp21_tests::test_suite! {
test = signing_with_presigs,
generics = all_curves,
suites = [
t3n5(Some(3), 5, false),
t3n5: (Some(3), 5, false),
#[cfg(feature = "hd-wallet")]
t3n5_hd(Some(3), 5, false),
t3n5_hd: (Some(3), 5, false),
]
}

Expand Down Expand Up @@ -221,12 +221,12 @@ cggmp21_tests::test_suite! {
test = signing_sync,
generics = all_curves,
suites = [
n3(None, 3, false),
t3n5(Some(3), 5, false),
n3: (None, 3, false),
t3n5: (Some(3), 5, false),
#[cfg(feature = "hd-wallet")]
n3_hd(None, 3, true),
n3_hd: (None, 3, true),
#[cfg(feature = "hd-wallet")]
t3n5_hd(Some(3), 5, true),
t3n5_hd: (Some(3), 5, true),
]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/it/trusted_dealer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cggmp21_tests::test_suite! {
test = trusted_dealer_generates_correct_shares,
generics = all_curves,
suites = [
test(),
test: (),
]
}
fn trusted_dealer_generates_correct_shares<E: Curve>() {
Expand Down

0 comments on commit 6026e03

Please sign in to comment.