Skip to content

Commit

Permalink
tests: do not use functions from extrakeys module
Browse files Browse the repository at this point in the history
This fixes a bug introduced in 7d2591c that
prevented compiling the library without enabling the extrakeys module.
  • Loading branch information
jonasnick committed Jul 24, 2024
1 parent 0055b86 commit af551ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#### Added
- Added usage example for an ElligatorSwift key exchange.

#### Fixed
- Fixed compilation when the extrakeys module is disabled.

## [0.5.0] - 2024-05-06

#### Added
Expand Down
14 changes: 3 additions & 11 deletions src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -6609,23 +6609,15 @@ static void permute(size_t *arr, size_t n) {
}
}

static void rand_pk(secp256k1_pubkey *pk) {
unsigned char seckey[32];
secp256k1_keypair keypair;
testrand256(seckey);
CHECK(secp256k1_keypair_create(CTX, &keypair, seckey) == 1);
CHECK(secp256k1_keypair_pub(CTX, pk, &keypair) == 1);
}

static void test_sort_api(void) {
secp256k1_pubkey pks[2];
const secp256k1_pubkey *pks_ptr[2];

pks_ptr[0] = &pks[0];
pks_ptr[1] = &pks[1];

rand_pk(&pks[0]);
rand_pk(&pks[1]);
testutil_random_pubkey_test(&pks[0]);
testutil_random_pubkey_test(&pks[1]);

CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1);
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_sort(CTX, NULL, 2));
Expand Down Expand Up @@ -6678,7 +6670,7 @@ static void test_sort(void) {
int j;
const secp256k1_pubkey *pk_ptr[5];
for (j = 0; j < 5; j++) {
rand_pk(&pk[j]);
testutil_random_pubkey_test(&pk[j]);
pk_ptr[j] = &pk[j];
}
secp256k1_ec_pubkey_sort(CTX, pk_ptr, 5);
Expand Down
6 changes: 6 additions & 0 deletions src/testutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ static void testutil_random_gej_test(secp256k1_gej *gej) {
testutil_random_ge_jacobian_test(gej, &ge);
}

static void testutil_random_pubkey_test(secp256k1_pubkey *pk) {
secp256k1_ge ge;
testutil_random_ge_test(&ge);
secp256k1_pubkey_save(pk, &ge);
}

static void testutil_random_scalar_order_test(secp256k1_scalar *num) {
do {
unsigned char b32[32];
Expand Down

0 comments on commit af551ab

Please sign in to comment.