test: make assumeUTXO test capture the expected fatal error #28050

pull furszy wants to merge 1 commits into bitcoin:master from furszy:2023_test_capture_assumeUTXO_fatal_error changing 1 files +6 −2
  1. furszy commented at 8:52 PM on July 7, 2023: member

    The test is exercising the error, so it can capture it before the test framework displays it on the console as an unforeseen fatal error.

    It is odd to observe a fatal error after executing the complete test suite and seeing it pass successfully.

    Reproduction Steps: Run the unit test suite. A long AssumeUTXO fatal error will be printed even when all tests pass successfully.

  2. DrahtBot commented at 8:52 PM on July 7, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theStack, MarcoFalke, TheCharlatan

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Jul 7, 2023
  4. test: make assumeUTXO test capture the expected fatal error
    The test is exercising the error, so it can capture it before
    the test framework displays it on the console as an unforeseen
    fatal error.
    3e8bf2e10c
  5. in src/test/validation_chainstatemanager_tests.cpp:668 in 56a1ecbe41 outdated
     665 | +    {
     666 | +        bool error_printed = false;
     667 | +        DebugLogHelper log_helper("Bitcoin Core failed to validate the -assumeutxo snapshot state", [&](const std::string* s) {
     668 | +            if (s) error_printed = true;
     669 | +            return false;
     670 | +        });
    


    maflcko commented at 6:25 AM on July 8, 2023:
            ASSERT_DEBUG_LOG ("failed to validate the -assumeutxo snapshot state");
    

    How is this different from just using the helper macro? Also, you can't use the hardcoded program name here. Finally, it may be good to add steps to reproduce/test for reviewers. Otherwise it is unclear what your goal is. Reading the description you are trying to avoid that some error string is output?


    furszy commented at 2:44 PM on July 8, 2023:

    Didn't know that the macro existed. Thanks.

    Finally, it may be good to add steps to reproduce/test for reviewers. Otherwise it is unclear what your goal is. Reading the description you are trying to avoid that some error string is output?

    Yeah. The chainstatemanager_snapshot_completion_hash_mismatch unit test manually triggers a fatal error, and the test framework by default prints the error message to the console (this one).

    So, just by running the unit test suite, you will see a long AssumeUTXO fatal error even when all tests passed successfully.

  6. furszy force-pushed on Jul 8, 2023
  7. furszy commented at 2:47 PM on July 8, 2023: member

    Updated per feedback, thanks @MarcoFalke.

    • Moved DebugLogHelper usage to ASSERT_DEBUG_LOG.
    • Added reproduction steps to the PR description.
  8. theStack approved
  9. theStack commented at 5:51 PM on July 9, 2023: contributor

    Tested ACK 3e8bf2e10c26ef9c2f58307b523e4b674ac97a2c

  10. maflcko commented at 6:50 AM on July 10, 2023: member

    Also it may be good to name the commit that introduced the bug. Otherwise it will be harder for reviewers to see if there was a bug in that commit or if the change was intentional. Also, reviewers will be missing context.

  11. furszy commented at 1:14 PM on July 10, 2023: member

    Also it may be good to name the commit that introduced the bug. Otherwise it will be harder for reviewers to see if there was a bug in that commit or if the change was intentional. Also, reviewers will be missing context.

    Ok. It was introduced with the test 87a1108c8. Still, this isn't as serious as you imagine. It is just an extra print. 100% sure that wasn't intended.

    The test is exercising a specific fatal error (checking that is being triggered), and doing so it makes the node call AbortNode. Which calls InitError which is connected to the noui signals interface, which is listened by the test framework base class, which prints the error to the console.

  12. maflcko commented at 1:17 PM on July 10, 2023: member

    Are you sure, because locally I don't see it in 25.0:

    $ ./bitcoin-25.0/bin/test_bitcoin  -t validation_chainstatemanager_tests/chainstatemanager_snapshot_completion_hash_mismatch 
    Running 1 test case...
    
    *** No errors detected
    
  13. furszy commented at 1:26 PM on July 10, 2023: member

    Are you sure, because locally I don't see it in 25.0:

    $ ./bitcoin-25.0/bin/test_bitcoin  -t validation_chainstatemanager_tests/chainstatemanager_snapshot_completion_hash_mismatch 
    Running 1 test case...
    
    *** No errors detected
    

    Ok good, found the commit. 6eb33bd0c21b3e075fbab596351cacafdc947472 introduced it. It removed the mock_shutdown function from the test (which was the one swalling the error).

  14. furszy commented at 1:29 PM on July 10, 2023: member

    cc @TheCharlatan then. Thanks @MarcoFalke.

  15. maflcko commented at 1:29 PM on July 10, 2023: member

    lgtm ACK 3e8bf2e10c26ef9c2f58307b523e4b674ac97a2c

  16. TheCharlatan approved
  17. TheCharlatan commented at 2:29 PM on July 10, 2023: contributor

    ACK 3e8bf2e10c26ef9c2f58307b523e4b674ac97a2c

    Thank you for fixing this.

  18. fanquake merged this on Jul 10, 2023
  19. fanquake closed this on Jul 10, 2023

  20. sidhujag referenced this in commit 9a86cec480 on Jul 12, 2023
  21. furszy deleted the branch on Jul 20, 2023
  22. bitcoin locked this on Jul 19, 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: 2026-04-16 00:13 UTC

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