Skip to content

Commit 1669bb2

Browse files
committed
Merge bitcoin#628: Fix ability to compile tests without -DVERIFY.
dcf3920 Fix ability to compile tests without -DVERIFY. (Gregory Maxwell) Pull request description: Broken by 3f3964e. It's important that the tests are also run without -DVERIFY due to the possibility that side-effects of a VERIFY_CHECK fix a bug that would otherwise be detected. Use of the verify_check macro in tests isn't sufficient. ACKs for commit dcf392: Tree-SHA512: ff7ca0e89e33f845656a4d7d18c0195d1378b020d67f89e900b18cf3d702aa81dd91ffd05a98953a481b83e4247eaf0c484bea12eab020efb3c966a456e8129f
2 parents ecc94ab + dcf3920 commit 1669bb2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/tests.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ void random_field_element_magnitude(secp256k1_fe *fe) {
8383
secp256k1_fe_negate(&zero, &zero, 0);
8484
secp256k1_fe_mul_int(&zero, n - 1);
8585
secp256k1_fe_add(fe, &zero);
86-
VERIFY_CHECK(fe->magnitude == n);
86+
#ifdef VERIFY
87+
CHECK(fe->magnitude == n);
88+
#endif
8789
}
8890

8991
void random_group_element_test(secp256k1_ge *ge) {
@@ -1819,24 +1821,32 @@ void run_field_misc(void) {
18191821
/* Test fe conditional move; z is not normalized here. */
18201822
q = x;
18211823
secp256k1_fe_cmov(&x, &z, 0);
1822-
VERIFY_CHECK(!x.normalized && x.magnitude == z.magnitude);
1824+
#ifdef VERIFY
1825+
CHECK(!x.normalized && x.magnitude == z.magnitude);
1826+
#endif
18231827
secp256k1_fe_cmov(&x, &x, 1);
18241828
CHECK(fe_memcmp(&x, &z) != 0);
18251829
CHECK(fe_memcmp(&x, &q) == 0);
18261830
secp256k1_fe_cmov(&q, &z, 1);
1827-
VERIFY_CHECK(!q.normalized && q.magnitude == z.magnitude);
1831+
#ifdef VERIFY
1832+
CHECK(!q.normalized && q.magnitude == z.magnitude);
1833+
#endif
18281834
CHECK(fe_memcmp(&q, &z) == 0);
18291835
secp256k1_fe_normalize_var(&x);
18301836
secp256k1_fe_normalize_var(&z);
18311837
CHECK(!secp256k1_fe_equal_var(&x, &z));
18321838
secp256k1_fe_normalize_var(&q);
18331839
secp256k1_fe_cmov(&q, &z, (i&1));
1834-
VERIFY_CHECK(q.normalized && q.magnitude == 1);
1840+
#ifdef VERIFY
1841+
CHECK(q.normalized && q.magnitude == 1);
1842+
#endif
18351843
for (j = 0; j < 6; j++) {
18361844
secp256k1_fe_negate(&z, &z, j+1);
18371845
secp256k1_fe_normalize_var(&q);
18381846
secp256k1_fe_cmov(&q, &z, (j&1));
1839-
VERIFY_CHECK(!q.normalized && q.magnitude == (j+2));
1847+
#ifdef VERIFY
1848+
CHECK(!q.normalized && q.magnitude == (j+2));
1849+
#endif
18401850
}
18411851
secp256k1_fe_normalize_var(&z);
18421852
/* Test storage conversion and conditional moves. */

0 commit comments

Comments
 (0)