tests: Tidy context tests #1186

pull real-or-random wants to merge 7 commits into bitcoin-core:master from real-or-random:202301-tidy-context-tests changing 4 files +147 −115
  1. real-or-random commented at 5:26 PM on January 4, 2023: contributor

    This is an improved version of some of the tidying/refactoring in #1170.

    I think it's enough to deserve a separate PR. Once this is merged, I'll get back to the actual goal of #1170 (namely, forbidding cloning and randomizing static contexts.)

    This PR is a general clean up of the context tests. A notable change is that this avoids a code smell where run_context_tests() would use the global ctx variable like a local one (i.e., create a context in it and destroy it afterwards). After this PR, the global ctx is properly initialized for all the other tests, and they can decide whether they want to use it or not. Same for a global sttc, which is a memcpy of the static context (we need a writable copy in order to be able to set callbacks).

    Note that this touches code which is also affected by #1167 but I refrained from trying to solve this issue. The goal of this PR is simply not to worsen the situation w.r.t. #1167. We should really introduce a macro to solve #1167 but that's another PR.

  2. tests: Use global copy of secp256k1_context_static instead of clone b19806122e
  3. tests: Don't recreate global context in scratch space test 18e0db30cb
  4. real-or-random force-pushed on Jan 4, 2023
  5. apoelstra commented at 7:40 PM on January 4, 2023: contributor

    valgrind does not pass on fc16b698. The next commit, 3c54c4adda8d79cdb574604757ffddc481096c9e, passes.

    I don't know if we have it as a goal that every commit passes valgrind, but there you go.

    Otherwise ACK 82d6a5a5a090cc920ff92842656e78889a25d0fd

  6. real-or-random force-pushed on Jan 5, 2023
  7. tests: Tidy run_context_tests() by extracting functions ce4f936c4f
  8. tests: Don't use global context for context tests f32a36f620
  9. refactor: Tidy up main() fc90bb5695
  10. tests: Clean up and improve run_context_tests() further a4a09379b1
  11. refactor: Separate run_context_tests into static vs proper contexts 39e8f0e3d7
  12. real-or-random force-pushed on Jan 5, 2023
  13. real-or-random commented at 9:34 AM on January 5, 2023: contributor

    I don't know if we have it as a goal that every commit passes valgrind, but there you go.

    Not strictly but I was certainly my intention here. Fixed.

    I tested every commit with valgrind now. (https://github.com/mhagger/git-test or https://github.com/spotify/git-test are really nice for this!)

  14. apoelstra approved
  15. apoelstra commented at 2:25 PM on January 5, 2023: contributor

    ACK 39e8f0e3d7ba7924e9cc5f9e0c56747e942f1eab

  16. sipa commented at 8:36 PM on January 5, 2023: contributor

    utACK 39e8f0e3d7ba7924e9cc5f9e0c56747e942f1eab

  17. real-or-random merged this on Jan 6, 2023
  18. real-or-random closed this on Jan 6, 2023

  19. real-or-random referenced this in commit cc3b8a4f40 on Jan 11, 2023
  20. dhruv referenced this in commit 4d33046ce3 on Feb 1, 2023
  21. dhruv referenced this in commit 55e7f2cf2b on Feb 2, 2023
  22. stratospher referenced this in commit 647f63669e on Feb 6, 2023
  23. dhruv referenced this in commit a4351c0df6 on Feb 20, 2023
  24. stratospher referenced this in commit 23f825fc8b on Feb 21, 2023
  25. hebasto referenced this in commit 7c0cc5d976 on Mar 7, 2023
  26. dhruv referenced this in commit a5df79db12 on Mar 7, 2023
  27. dhruv referenced this in commit 77b510d84c on Mar 7, 2023
  28. sipa referenced this in commit 763079a3f1 on Mar 8, 2023
  29. div72 referenced this in commit 945b094575 on Mar 14, 2023
  30. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  31. vmta referenced this in commit 8f03457eed on Jul 1, 2023
  32. delta1 referenced this in commit 3f32c20932 on Aug 8, 2023
  33. delta1 referenced this in commit 31ac0c1081 on Aug 31, 2023
  34. janus referenced this in commit 4816e2a921 on Sep 3, 2023
  35. backpacker69 referenced this in commit 26f6d832fb on Mar 5, 2024
  36. str4d referenced this in commit b350ac56ac on Jun 4, 2025
  37. Fabcien referenced this in commit 098b5c8c4e on Mar 7, 2026
  38. Fabcien referenced this in commit 842edfeb21 on Mar 7, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC