qa: Avoid knock-on exception in assert_start_raises_init_error #32929

pull hodlinator wants to merge 4 commits into bitcoin:master from hodlinator:2025/07/raise_outside_except changing 2 files +49 −10
  1. hodlinator commented at 9:39 pm on July 9, 2025: contributor

    Raising a new exception from within a Python except-block causes the interpreter to generate extra error output which is unnecessary in this case.

    Found while testing #32835 using the suggested method (https://github.com/bitcoin/bitcoin/pull/32835#issue-3188748624) which triggered expected timeouts, but with the extra error noise.

    Before:

     02025-07-08T20:05:48.407001Z TestFramework (ERROR): Assertion failed
     1Traceback (most recent call last):
     2  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_node.py", line 686, in assert_start_raises_init_error
     3    ret = self.process.wait(timeout=self.rpc_timeout)
     4          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     5  File "/nix/store/fqm9bqqlmaqqr02qbalm1bazp810qfiw-python3-3.12.9/lib/python3.12/subprocess.py", line 1266, in wait
     6    return self._wait(timeout=timeout)
     7           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
     8  File "/nix/store/fqm9bqqlmaqqr02qbalm1bazp810qfiw-python3-3.12.9/lib/python3.12/subprocess.py", line 2053, in _wait
     9    raise TimeoutExpired(self.args, timeout)
    10subprocess.TimeoutExpired: Command '['/home/hodlinator/bitcoin/build/bin/bitcoind', '-datadir=/tmp/bitcoin_func_test_v96lkcq8/eb2665c7/node0', '-logtimemicros', '-debug', '-debugexclude=libevent', '-debugexclude=leveldb', '-debugexclude=rand', '-uacomment=testnode0', '-disablewallet', '-logthreadnames', '-logsourcelocations', '-loglevel=trace', '-v2transport=0']' timed out after 3 seconds
    11
    12During handling of the above exception, another exception occurred:
    13
    14Traceback (most recent call last):
    15  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_framework.py", line 186, in main
    16    self.setup()
    17  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_framework.py", line 358, in setup
    18    self.setup_network()
    19  File "/home/hodlinator/bitcoin/build/test/functional/feature_framework_startup_failures.py", line 151, in setup_network
    20    self.nodes[0].assert_start_raises_init_error()
    21  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_node.py", line 716, in assert_start_raises_init_error
    22    self._raise_assertion_error(assert_msg)
    23  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_node.py", line 196, in _raise_assertion_error
    24    raise AssertionError(self._node_msg(msg))
    25AssertionError: [node 0] bitcoind should have exited within 3s with an error
    

    After:

     02025-07-08T20:09:15.330589Z TestFramework (ERROR): Assertion failed
     1Traceback (most recent call last):
     2  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_framework.py", line 186, in main
     3    self.setup()
     4  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_framework.py", line 358, in setup
     5    self.setup_network()
     6  File "/home/hodlinator/bitcoin/build/test/functional/feature_framework_startup_failures.py", line 151, in setup_network
     7    self.nodes[0].assert_start_raises_init_error()
     8  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_node.py", line 720, in assert_start_raises_init_error
     9    self._raise_assertion_error(assert_msg)
    10  File "/home/hodlinator/bitcoin/test/functional/test_framework/test_node.py", line 196, in _raise_assertion_error
    11    raise AssertionError(self._node_msg(msg))
    12AssertionError: [node 0] bitcoind should have exited within 3s with an error
    

    Can be tested by:

    1. Execute test containing new test case:
      0build/test/functional/feature_framework_startup_failures.py -ldebug > after.log
      
    2. Drop first commit which contains the fix.
    3. Re-run test:
      0build/test/functional/feature_framework_startup_failures.py -ldebug > before.log
      
    4. Diff logs, focusing on TestInitErrorTimeout OUTPUT sections.
  2. qa: assert_start_raises_init_error - Don't trigger as knock-on exception
    Prevents "During handling of the above exception, another exception occurred"-output which re-raising within the except-block would trigger.
    b924de8127
  3. refactor(qa): Extract InternalDurationTestMixin for use in next commit a126e46593
  4. qa: Add test for init error timeout behavior 8064d2257f
  5. DrahtBot added the label Tests on Jul 9, 2025
  6. DrahtBot commented at 9:39 pm on July 9, 2025: 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/32929.

    Reviews

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

  7. qa: Log expected output in debug
    Helpful when comparing expected/unexpected outputs against each other for working/broken code.
    e587c5af4e
  8. hodlinator force-pushed on Jul 9, 2025
  9. DrahtBot added the label CI failed on Jul 9, 2025
  10. DrahtBot commented at 9:47 pm on July 9, 2025: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin/bitcoin/runs/45676665634 LLM reason (✨ experimental): Lint check failed due to a Python f-string syntax error in the code.

    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.

  11. fanquake commented at 10:05 am on July 10, 2025: member
    (Test failure here was fixed in #32932)

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-07-11 09:13 UTC

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