tests: Use global copy of secp256k1_context_static instead of clone

This commit is contained in:
Tim Ruffing
2022-12-07 14:56:43 +01:00
parent 2a39ac162e
commit b19806122e
4 changed files with 19 additions and 16 deletions

View File

@@ -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);
@@ -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) {

View File

@@ -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;
@@ -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) {

View File

@@ -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);
@@ -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