[WIP] test: add unit tests for SigningResultString function #31566

pull lucasbalieiro wants to merge 1 commits into bitcoin:master from lucasbalieiro:test/common-signmessage changing 1 files +9 −0
  1. lucasbalieiro commented at 8:39 pm on December 24, 2024: none

    This PR introduces new unit tests for the SigningResultString function located in the file src/common/signmessage.cpp.

    Motivation:

    Prior to this PR, the SigningResultString function had no test coverage. This update adds the necessary test cases to ensure that the function behaves as expected.

    Changes:

    • Added unit tests to cover all the cases in the switch statement within the SigningResultString function.
    • Ensured that each valid SigningResult enum value is tested for the expected output string:
      • SigningResult::OK
      • SigningResult::PRIVATE_KEY_NOT_AVAILABLE
      • SigningResult::SIGNING_FAILED
    • Placed the new tests in the file location that matches the context of other related tests, ensuring consistency in test organization.

    Suggested Follow-Up:

    The current implementation of the function includes an assert(false) for invalid enum values, as there is no default case in the switch statement. Since modifying the original function is not within the scope of this PR, perhaps someone with more C++ experience could explore writing a test to verify the behavior of the assert and the compiler warnings referenced in the comment:

    // no default case, so the compiler can warn about missing cases

  2. DrahtBot commented at 8:39 pm on December 24, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31566.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  3. DrahtBot added the label Tests on Dec 24, 2024
  4. lucasbalieiro marked this as a draft on Dec 24, 2024
  5. lucasbalieiro renamed this:
    test: add unit tests for SigningResultString function
    [WIP] test: add unit tests for SigningResultString function
    on Dec 24, 2024
  6. test: add unit tests for SigningResultString function 6d4536afe8
  7. lucasbalieiro force-pushed on Dec 24, 2024
  8. DrahtBot commented at 9:03 pm on December 24, 2024: contributor

    🚧 At least one of the CI tasks failed. Debug: https://github.com/bitcoin/bitcoin/runs/34845567696

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  9. DrahtBot added the label CI failed on Dec 24, 2024
  10. lucasbalieiro closed this on Dec 24, 2024

  11. lucasbalieiro deleted the branch on Dec 25, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-01-18 03:12 UTC

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