test: deduplicate scalar and field constants for n-1 and p-1#1820
Open
therohityadav wants to merge 1 commit intobitcoin-core:masterfrom
Open
test: deduplicate scalar and field constants for n-1 and p-1#1820therohityadav wants to merge 1 commit intobitcoin-core:masterfrom
therohityadav wants to merge 1 commit intobitcoin-core:masterfrom
Conversation
ab653ab to
d31d8c0
Compare
d31d8c0 to
8c35adf
Compare
Contributor
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
Contributor
Author
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.