Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4

17065f48ae261c6949dab74a7c197ac13b52eb1b tests: Randomize the context with probability 15/16 instead of 1/4 (Tim Ruffing)

Pull request description:

ACKs for top commit:
  sipa:
    ACK 17065f48ae261c6949dab74a7c197ac13b52eb1b
  jonasnick:
    ACK 17065f48ae261c6949dab74a7c197ac13b52eb1b

Tree-SHA512: 3b7005770007b922a294be610f23da60b0dde74dfd7585d64a2cb04eaa6ec879de8d21a0ade31c1857019a8dd97260fa3aa167ae16fc55027ef280a3e3feaa6d
This commit is contained in:
Jonas Nick 2022-07-11 11:18:58 +00:00
commit 6a873cc4a9
No known key found for this signature in database
GPG Key ID: 4861DBF262123605

View File

@ -7086,11 +7086,15 @@ int main(int argc, char **argv) {
run_context_tests(0); run_context_tests(0);
run_context_tests(1); run_context_tests(1);
run_scratch_tests(); run_scratch_tests();
ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
if (secp256k1_testrand_bits(1)) { /* Randomize the context only with probability 15/16
to make sure we test without context randomization from time to time.
TODO Reconsider this when recalibrating the tests. */
if (secp256k1_testrand_bits(4)) {
unsigned char rand32[32]; unsigned char rand32[32];
secp256k1_testrand256(rand32); secp256k1_testrand256(rand32);
CHECK(secp256k1_context_randomize(ctx, secp256k1_testrand_bits(1) ? rand32 : NULL)); CHECK(secp256k1_context_randomize(ctx, rand32));
} }
run_rand_bits(); run_rand_bits();