tests: refactor: tidy up util functions (#1491) #1533

pull theStack wants to merge 5 commits into bitcoin-core:master from theStack:util_functions_cleanup changing 11 files +397 −400
  1. theStack commented at 1:25 AM on May 27, 2024: contributor

    This PR is an attempt at tidying up test util functions, as suggested in #1491. The following changes are done:

    • rename _group_element... functions to _ge...
    • rename _field_element... functions to _fe...
    • move random_ helpers from tests.c to testutil.h (the alternative would be testrand.h, but to my understanding, this one is meant to contain the actual RNG implementation rather than helpers using it; happy to move the helpers there if that is preferred though)
    • prefix testutil.h functions with testutil_
    • prefix testrand.h functions with testrand_ (this is currently done in a sloppy way by simply dropping the secp256k1_ prefix, so some functions don't have the full prefix, like e.g. testrand256; naming suggestions welcome)
  2. tests: refactor: rename `random_group_element_...` -> `random_ge_...`
    The rename was done with the following command:
    
    $ sed -i 's/random_group_element_/random_ge_/g' $(git grep -l random_group_element_)
    59db007f0f
  3. tests: refactor: rename `random_field_element_magnitude` -> `random_fe_magnitude`
    Note that the already existing function `random_fe_magnitude` is removed
    and the call-sites are adapted to pass the magnitude range of 8
    (the maximum for secp256k1_fe_mul and secp256k1_fe_sqr) explicitly.
    0fef8479be
  4. tests: refactor: move `random_` helpers from tests.c to testutil.h
    Can be reviewed via `--color-moved=dimmed-zebra`.
    0c6bc76dcd
  5. tests: refactor: add `testutil_` prefix to testutil.h functions 0ee7453a99
  6. tests: refactor: drop `secp256k1_` prefix from testrand.h functions
    The rename was done with the following command:
    
    $ sed -i 's/secp256k1_testrand/testrand/g' $(git grep -l secp256k1_testrand)
    e73f6f8fd9
  7. theStack force-pushed on May 27, 2024
  8. real-or-random approved
  9. real-or-random commented at 12:34 PM on May 27, 2024: contributor

    utACK e73f6f8fd9158a044c6fb22653105446f3542bb0

  10. real-or-random added the label assurance on May 27, 2024
  11. real-or-random added the label refactor/smell on May 27, 2024
  12. sipa commented at 4:01 PM on May 27, 2024: contributor

    What is up with the macOS CI?

  13. real-or-random commented at 8:42 PM on May 27, 2024: contributor

    What is up with the macOS CI?

    See https://github.com/bitcoin-core/secp256k1/issues/1536

  14. real-or-random commented at 8:25 AM on June 11, 2024: contributor

    @sipa Want to review this?

  15. sipa commented at 1:25 PM on June 12, 2024: contributor

    utACK e73f6f8fd9158a044c6fb22653105446f3542bb0

  16. real-or-random merged this on Jun 12, 2024
  17. real-or-random closed this on Jun 12, 2024

  18. theStack deleted the branch on Jun 13, 2024
  19. fanquake referenced this in commit b941c15808 on Jun 25, 2024
  20. hebasto referenced this in commit b20389c74a on Jun 25, 2024
  21. fanquake referenced this in commit 1408944d2e on Jun 25, 2024
  22. achow101 referenced this in commit 9ac4f69ec2 on Jun 26, 2024
  23. vmta referenced this in commit bafdd96c0a on Jul 3, 2024
  24. janus referenced this in commit 411aef6677 on Jul 26, 2024
  25. vmta referenced this in commit 871c80c433 on Sep 6, 2024
  26. vmta referenced this in commit 4d1f6d5635 on Oct 29, 2024
  27. div72 referenced this in commit af627d47c3 on Apr 12, 2025
  28. oskarszoon referenced this in commit 0d5c9260f4 on Jul 1, 2025
  29. github-actions[bot] referenced this in commit 758d4e90b4 on Mar 1, 2026
  30. github-actions[bot] referenced this in commit 68a2178f22 on Mar 1, 2026
  31. github-actions[bot] referenced this in commit a8bc1a0b2b on Mar 1, 2026
  32. 0x000000000019d6689c085ae165831e934ff76 referenced this in commit 3b9450150d on Mar 2, 2026
  33. csjones referenced this in commit a4d92824ae on Mar 2, 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