tests: Improve secp256k1_scalar_check_overflow tests (Issue #1812)#1819
Conversation
hebasto
left a comment
There was a problem hiding this comment.
Trailing spaces should be removed to pass the CI.
Thank you, I have removed the trailing whitespace and all the tests passed. |
Thanks, and please squash your commits. :) |
58be14b to
83568d8
Compare
Thanks for the Concept ACK and the review! I have addressed all the feedback:
|
|
I don't see any diff compared to your last push. (See https://github.com/bitcoin-core/secp256k1/compare/58be14be2de04cc39df0f286826f0b19b8809fe0..83568d863521ba25a2f3bc791f0776a898cdb2cb) But I see you squashed. Did you push the wrong commit? |
83568d8 to
1cee90f
Compare
real-or-random
left a comment
There was a problem hiding this comment.
Thanks for the update, I have just one more comment
src/tests.c
Outdated
| CHECK(secp256k1_scalar_check_overflow(&n_plus_1) == 1); | ||
| CHECK(secp256k1_scalar_check_overflow(&max) == 1); | ||
|
|
||
| for (i = 0; i < count; i++) { |
There was a problem hiding this comment.
I literally meant COUNT, a global variable in the tests. This loop could run 2 * COUNT times, I think.
There was a problem hiding this comment.
I literally meant
COUNT, a global variable in the tests. This loop could run2 * COUNTtimes, I think.
Thank you for the catch. I have removed the local count variable and updated the loop to use the global COUNT with 2 * COUNT iterations.
1cee90f to
6b49efd
Compare
|
|
||
| static void run_scalar_tests(void) { | ||
| int i; | ||
| test_scalar_check_overflow(); |
There was a problem hiding this comment.
non-blocking nit: could add a newline before to separate the declaration block
There was a problem hiding this comment.
non-blocking nit: could add a newline before to separate the declaration block
I have added the newline to separate the declaration block.
Regarding the scalar constant deduplication: I am looking into doing that in a follow-up PR to keep this one focused.
6b49efd to
1e7dfc0
Compare
1e7dfc0 to
f47bbc0
Compare
|
Thanks for your contribution! |
This Pull Request improves the tests for
secp256k1_scalar_check_overflowas requested in #1812.Changes:
run_scalar_tests.test_scalar_check_overflow.0,N-1,N,N+1, andMAX.check_overflowagainst a manual byte comparison.Fixes #1812.