diff --git a/src/tests.c b/src/tests.c index 5b7c914f8c..b4792ebe9d 100644 --- a/src/tests.c +++ b/src/tests.c @@ -2967,16 +2967,9 @@ static void random_fe(secp256k1_fe *x) { } static void random_fe_non_zero(secp256k1_fe *nz) { - int tries = 10; - while (--tries >= 0) { + do { random_fe(nz); - secp256k1_fe_normalize(nz); - if (!secp256k1_fe_is_zero(nz)) { - break; - } - } - /* Infinitesimal probability of spurious failure here */ - CHECK(tries >= 0); + } while (secp256k1_fe_is_zero(nz)); } static void random_fe_non_square(secp256k1_fe *ns) { diff --git a/src/tests_exhaustive.c b/src/tests_exhaustive.c index 3af8ec1ee5..6cab1a6943 100644 --- a/src/tests_exhaustive.c +++ b/src/tests_exhaustive.c @@ -70,16 +70,9 @@ static void random_fe(secp256k1_fe *x) { } static void random_fe_non_zero(secp256k1_fe *nz) { - int tries = 10; - while (--tries >= 0) { + do { random_fe(nz); - secp256k1_fe_normalize(nz); - if (!secp256k1_fe_is_zero(nz)) { - break; - } - } - /* Infinitesimal probability of spurious failure here */ - CHECK(tries >= 0); + } while (secp256k1_fe_is_zero(nz)); } /** END stolen from tests.c */