selftest: Expose in public API
This commit is contained in:
@@ -73,6 +73,12 @@ static const secp256k1_context secp256k1_context_static_ = {
|
||||
const secp256k1_context *secp256k1_context_static = &secp256k1_context_static_;
|
||||
const secp256k1_context *secp256k1_context_no_precomp = &secp256k1_context_static_;
|
||||
|
||||
void secp256k1_selftest(void) {
|
||||
if (!secp256k1_selftest_passes()) {
|
||||
secp256k1_callback_call(&default_error_callback, "self test failed");
|
||||
}
|
||||
}
|
||||
|
||||
size_t secp256k1_context_preallocated_size(unsigned int flags) {
|
||||
size_t ret = sizeof(secp256k1_context);
|
||||
/* A return value of 0 is reserved as an indicator for errors when we call this function internally. */
|
||||
@@ -97,9 +103,7 @@ secp256k1_context* secp256k1_context_preallocated_create(void* prealloc, unsigne
|
||||
size_t prealloc_size;
|
||||
secp256k1_context* ret;
|
||||
|
||||
if (!secp256k1_selftest_passes()) {
|
||||
secp256k1_callback_call(&default_error_callback, "self test failed");
|
||||
}
|
||||
secp256k1_selftest();
|
||||
|
||||
prealloc_size = secp256k1_context_preallocated_size(flags);
|
||||
if (prealloc_size == 0) {
|
||||
|
||||
@@ -141,6 +141,11 @@ void random_scalar_order_b32(unsigned char *b32) {
|
||||
secp256k1_scalar_get_b32(b32, &num);
|
||||
}
|
||||
|
||||
void run_selftest_tests(void) {
|
||||
/* Test public API */
|
||||
secp256k1_selftest();
|
||||
}
|
||||
|
||||
void run_context_tests(int use_prealloc) {
|
||||
secp256k1_pubkey pubkey;
|
||||
secp256k1_pubkey zero_pubkey;
|
||||
@@ -7388,6 +7393,7 @@ int main(int argc, char **argv) {
|
||||
secp256k1_testrand_init(argc > 2 ? argv[2] : NULL);
|
||||
|
||||
/* initialize */
|
||||
run_selftest_tests();
|
||||
run_context_tests(0);
|
||||
run_context_tests(1);
|
||||
run_scratch_tests();
|
||||
|
||||
Reference in New Issue
Block a user