@@ -228,7 +228,23 @@ void run_ec_illegal_argument_tests(void) {
228
228
secp256k1_context_set_illegal_callback (ctx , NULL , NULL );
229
229
}
230
230
231
- void run_context_tests (int use_prealloc ) {
231
+ void run_static_context_tests (void ) {
232
+ int32_t dummy = 0 ;
233
+
234
+ /* Check that deprecated secp256k1_context_no_precomp is an alias to secp256k1_context_static. */
235
+ CHECK (secp256k1_context_no_precomp == secp256k1_context_static );
236
+
237
+ /* check if sizes for cloning are consistent */
238
+ CHECK (secp256k1_context_preallocated_clone_size (sttc ) >= sizeof (secp256k1_context ));
239
+
240
+ /* Verify that setting and resetting illegal callback works */
241
+ secp256k1_context_set_illegal_callback (sttc , counting_illegal_callback_fn , & dummy );
242
+ CHECK (sttc -> illegal_callback .fn == counting_illegal_callback_fn );
243
+ secp256k1_context_set_illegal_callback (sttc , NULL , NULL );
244
+ CHECK (sttc -> illegal_callback .fn == secp256k1_default_illegal_callback_fn );
245
+ }
246
+
247
+ void run_proper_context_tests (int use_prealloc ) {
232
248
int32_t dummy = 0 ;
233
249
secp256k1_context * my_ctx ;
234
250
void * my_ctx_prealloc = NULL ;
@@ -237,10 +253,6 @@ void run_context_tests(int use_prealloc) {
237
253
secp256k1_ge pub ;
238
254
secp256k1_scalar msg , key , nonce ;
239
255
secp256k1_scalar sigr , sigs ;
240
-
241
- /* Check that deprecated secp256k1_context_no_precomp is an alias to secp256k1_context_static. */
242
- CHECK (secp256k1_context_no_precomp == secp256k1_context_static );
243
-
244
256
if (use_prealloc ) {
245
257
my_ctx_prealloc = malloc (secp256k1_context_preallocated_size (SECP256K1_CONTEXT_NONE ));
246
258
CHECK (my_ctx_prealloc != NULL );
@@ -256,7 +268,6 @@ void run_context_tests(int use_prealloc) {
256
268
257
269
/* check if sizes for cloning are consistent */
258
270
CHECK (secp256k1_context_preallocated_clone_size (my_ctx ) == secp256k1_context_preallocated_size (SECP256K1_CONTEXT_NONE ));
259
- CHECK (secp256k1_context_preallocated_clone_size (sttc ) >= sizeof (secp256k1_context ));
260
271
261
272
/*** clone and destroy all of them to make sure cloning was complete ***/
262
273
{
@@ -286,11 +297,6 @@ void run_context_tests(int use_prealloc) {
286
297
CHECK (my_ctx -> error_callback .fn == secp256k1_default_error_callback_fn );
287
298
288
299
/* Verify that setting and resetting illegal callback works */
289
- secp256k1_context_set_illegal_callback (sttc , counting_illegal_callback_fn , & dummy );
290
- CHECK (sttc -> illegal_callback .fn == counting_illegal_callback_fn );
291
- secp256k1_context_set_illegal_callback (sttc , NULL , NULL );
292
- CHECK (sttc -> illegal_callback .fn == secp256k1_default_illegal_callback_fn );
293
-
294
300
secp256k1_context_set_illegal_callback (my_ctx , counting_illegal_callback_fn , & dummy );
295
301
CHECK (my_ctx -> illegal_callback .fn == counting_illegal_callback_fn );
296
302
secp256k1_context_set_illegal_callback (my_ctx , NULL , NULL );
@@ -7384,8 +7390,9 @@ int main(int argc, char **argv) {
7384
7390
run_selftest_tests ();
7385
7391
7386
7392
/* context tests */
7387
- run_context_tests (0 );
7388
- run_context_tests (1 );
7393
+ run_proper_context_tests (0 );
7394
+ run_proper_context_tests (1 );
7395
+ run_static_context_tests ();
7389
7396
run_deprecated_context_flags_test ();
7390
7397
7391
7398
/* scratch tests */
0 commit comments