Skip to content

Commit 49be5be

Browse files
Merge #1390: tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID
7030364 tests: add CHECK_ERROR_VOID and use it in scratch tests (Jonas Nick) f8d7ea6 tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID (Jonas Nick) a1d52e3 tests: remove unnecessary test in run_ec_pubkey_parse_test (Jonas Nick) 875b0ad tests: remove unnecessary set_illegal_callback (Jonas Nick) Pull request description: Fixes #1167 ACKs for top commit: siv2r: reACK 7030364 (tests pass locally) real-or-random: reACK 7030364 Tree-SHA512: 0ca1f1c92a1c3a93b412433e53e882be56f3c7c55d4cbf12683ab7d9b8a916231b6508270099bfed0bfaa9d0af19cb8fdf0fe3274112ab48d33a0bd2356f2fa7
2 parents cbf3053 + 7030364 commit 49be5be

File tree

5 files changed

+180
-501
lines changed

5 files changed

+180
-501
lines changed

src/modules/ecdh/tests_impl.h

+6-19
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,19 @@ static int ecdh_hash_function_custom(unsigned char *output, const unsigned char
2525
}
2626

2727
static void test_ecdh_api(void) {
28-
/* Setup context that just counts errors */
29-
secp256k1_context *tctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
3028
secp256k1_pubkey point;
3129
unsigned char res[32];
3230
unsigned char s_one[32] = { 0 };
33-
int32_t ecount = 0;
3431
s_one[31] = 1;
3532

36-
secp256k1_context_set_error_callback(tctx, counting_illegal_callback_fn, &ecount);
37-
secp256k1_context_set_illegal_callback(tctx, counting_illegal_callback_fn, &ecount);
38-
CHECK(secp256k1_ec_pubkey_create(tctx, &point, s_one) == 1);
33+
CHECK(secp256k1_ec_pubkey_create(CTX, &point, s_one) == 1);
3934

4035
/* Check all NULLs are detected */
41-
CHECK(secp256k1_ecdh(tctx, res, &point, s_one, NULL, NULL) == 1);
42-
CHECK(ecount == 0);
43-
CHECK(secp256k1_ecdh(tctx, NULL, &point, s_one, NULL, NULL) == 0);
44-
CHECK(ecount == 1);
45-
CHECK(secp256k1_ecdh(tctx, res, NULL, s_one, NULL, NULL) == 0);
46-
CHECK(ecount == 2);
47-
CHECK(secp256k1_ecdh(tctx, res, &point, NULL, NULL, NULL) == 0);
48-
CHECK(ecount == 3);
49-
CHECK(secp256k1_ecdh(tctx, res, &point, s_one, NULL, NULL) == 1);
50-
CHECK(ecount == 3);
51-
52-
/* Cleanup */
53-
secp256k1_context_destroy(tctx);
36+
CHECK(secp256k1_ecdh(CTX, res, &point, s_one, NULL, NULL) == 1);
37+
CHECK_ILLEGAL(CTX, secp256k1_ecdh(CTX, NULL, &point, s_one, NULL, NULL));
38+
CHECK_ILLEGAL(CTX, secp256k1_ecdh(CTX, res, NULL, s_one, NULL, NULL));
39+
CHECK_ILLEGAL(CTX, secp256k1_ecdh(CTX, res, &point, NULL, NULL, NULL));
40+
CHECK(secp256k1_ecdh(CTX, res, &point, s_one, NULL, NULL) == 1);
5441
}
5542

5643
static void test_ecdh_generator_basepoint(void) {

0 commit comments

Comments
 (0)