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

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: 2024-11-21 08:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me