test: deduplicate scalar and field constants for n-1 and p-1#1820
test: deduplicate scalar and field constants for n-1 and p-1#1820therohityadav wants to merge 1 commit intobitcoin-core:masterfrom
Conversation
ab653ab to
d31d8c0
Compare
d31d8c0 to
8c35adf
Compare
real-or-random
left a comment
There was a problem hiding this comment.
Concept ~0
I'm not convinced this really improves readability or maintainability
Thanks for the review @real-or-random. I understand the concern about readability . having explicit values in tests is often preferred. However, my idea here was to treat n-1 and p-1 as constants rather than arbitrary test vectors. By defining them in one place , we eliminate the risk of typos that could occur when these hex strings are repeated across the file. It ensures that every test checking these boundaries is mathematically guaranteed to be checking the same boundary. |
|
I'm still not convinced that I want to spend time on this, but let me leave as a note here that a new test relevant to this PR has been added in b99a94c. |
Following up on feedback from #1819, this PR deduplicates the hardcoded constants for the group order minus one (n-1) and the field prime minus one (p-1) within
src/tests.c.Changes:
scalar_n_m1andfe_p_m1as global static constants at the top of the file.test_scalar_check_overflowrun_scalar_tests(HALF_TESTS)scalar_cmov_testscalar_casesandfe_casesarraysscalar_minus_oneandfe_minus_onedefinitions.make checkpasses all tests.