Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Tidy context tests #1186

Merged
5 changes: 3 additions & 2 deletions src/modules/extrakeys/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ void test_keypair(void) {
secp256k1_xonly_pubkey xonly_pk, xonly_pk_tmp;
int pk_parity, pk_parity_tmp;
int ecount;
secp256k1_context *sttc = secp256k1_context_clone(secp256k1_context_static);

set_counting_callbacks(ctx, &ecount);
set_counting_callbacks(sttc, &ecount);
Expand Down Expand Up @@ -440,7 +439,9 @@ void test_keypair(void) {
memset(&keypair, 0, sizeof(keypair));
CHECK(secp256k1_keypair_sec(ctx, sk_tmp, &keypair) == 1);
CHECK(secp256k1_memcmp_var(zeros96, sk_tmp, sizeof(sk_tmp)) == 0);
secp256k1_context_destroy(sttc);

secp256k1_context_set_error_callback(sttc, NULL, NULL);
secp256k1_context_set_illegal_callback(sttc, NULL, NULL);
}

void test_keypair_add(void) {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/recovery/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ static int recovery_test_nonce_function(unsigned char *nonce32, const unsigned c

void test_ecdsa_recovery_api(void) {
/* Setup contexts that just count errors */
secp256k1_context *sttc = secp256k1_context_clone(secp256k1_context_static);
secp256k1_pubkey pubkey;
secp256k1_pubkey recpubkey;
secp256k1_ecdsa_signature normal_sig;
Expand Down Expand Up @@ -124,7 +123,8 @@ void test_ecdsa_recovery_api(void) {
CHECK(ecount == 7);

/* cleanup */
secp256k1_context_destroy(sttc);
secp256k1_context_set_error_callback(sttc, NULL, NULL);
secp256k1_context_set_illegal_callback(sttc, NULL, NULL);
}

void test_ecdsa_recovery_end_to_end(void) {
Expand Down
6 changes: 3 additions & 3 deletions src/modules/schnorrsig/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void test_schnorrsig_api(void) {
secp256k1_schnorrsig_extraparams invalid_extraparams = {{ 0 }, NULL, NULL};

/** setup **/
secp256k1_context *sttc = secp256k1_context_clone(secp256k1_context_static);
int ecount;
int ecount = 0;

secp256k1_context_set_error_callback(ctx, counting_illegal_callback_fn, &ecount);
secp256k1_context_set_illegal_callback(ctx, counting_illegal_callback_fn, &ecount);
Expand Down Expand Up @@ -198,7 +197,8 @@ void test_schnorrsig_api(void) {
CHECK(secp256k1_schnorrsig_verify(ctx, sig, msg, sizeof(msg), &zero_pk) == 0);
CHECK(ecount == 4);

secp256k1_context_destroy(sttc);
secp256k1_context_set_error_callback(sttc, NULL, NULL);
secp256k1_context_set_illegal_callback(sttc, NULL, NULL);
}

/* Checks that hash initialized by secp256k1_schnorrsig_sha256_tagged has the
Expand Down
Loading