-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve: add some macros to generate big testing suite of fields #131
improve: add some macros to generate big testing suite of fields #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That -700 lines is really good to see! 👍
I have given the PR a pass and it looks good so far. I've left a couple of suggestions.
Will approve it as I check the parts that I'm missing.
Nice work :)
src/tests/field.rs
Outdated
macro_rules! random_multiplication_tests { | ||
($f: ident, $rng: expr) => { | ||
let _message = format!("multiplication {}", stringify!($f)); | ||
let start = start_timer!(|| _message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these timers are quite unnecessary so I suggest removing them form all tests.
We can get rid of the ark-std
dev-dependency as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unnecessary timer
s in b549998
Regarding the ark-std
dep, it is used in several places.
For example, it is for feature print-trace
, msm testing
, and bn256::Fr benchmarking
I think we should keep ark-std
dep because of these usages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're right, I forgot about those. Let's keep it then.
src/tests/field.rs
Outdated
#[macro_export] | ||
macro_rules! field_testing_suite { | ||
($field: ident, "field_arithmetic") => { | ||
macro_rules! random_multiplication_tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for having these inner macros?
The outer macro is really nice, but I think these ones could be normal functions and the code would be simpler. I've made a suggestion here: davidnevadoc@a81fe26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done f54b70c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for this good work! 👍
0x3c208c16d87cfd47, | ||
0x97816a916871ca8d, | ||
0xb85045b68181585d, | ||
0x30644e72e131a029, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we comment how we obtained this? Or from where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ | ||
0x3c208c16d87cfd47, | ||
0x97816a916871ca8d, | ||
0xb85045b68181585d, | ||
0x30644e72e131a029, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
[ | ||
0x3c208c16d87cfd47, | ||
0x97816a916871ca8d, | ||
0xb85045b68181585d, | ||
0x30644e72e131a029, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
0x9ffffcd300000001, | ||
0xa2a7e8c30006b945, | ||
0xe4a7a5fe8fadffd6, | ||
0x443f9a5cda8a6c7b, | ||
0xa803ca76f439266f, | ||
0x0130e0000d7f70e4, | ||
0x2400000000002400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
0x9ffffcd300000001, | ||
0xa2a7e8c30006b945, | ||
0xe4a7a5fe8fadffd6, | ||
0x443f9a5cda8a6c7b, | ||
0xa803ca76f439266f, | ||
0x0130e0000d7f70e4, | ||
0x2400000000002400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
[ | ||
0x9ffffcd300000001, | ||
0xa2a7e8c30006b945, | ||
0xe4a7a5fe8fadffd6, | ||
0x443f9a5cda8a6c7b, | ||
0xa803ca76f439266f, | ||
0x0130e0000d7f70e4, | ||
0x2400000000002400, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing refactor! :)
is assert_eq!(Fr::DELTA, GENERATOR.pow([1u64 << Fr::S]))
implemented? I only see it for MULTIPLICATIVE_GENERATOR
src/secp256r1/fq.rs
Outdated
crate::field_testing_suite!(Fq, "conversion"); | ||
crate::field_testing_suite!(Fq, "serialization"); | ||
crate::field_testing_suite!(Fq, "quadratic_residue"); | ||
// crate::field_testing_suite!(Fq, "bits"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get rid of this test on purpose. |
f96f7f9
Description
Related issues
Changes
field_testing_suite
macro for tests of fields