test: add coverage for bitcoin wrapper argument handling #36022

pull cyb3ralbert wants to merge 1 commits into bitcoin:master from cyb3ralbert:test-bitcoin-multitool-coverage changing 1 files +50 −0
  1. cyb3ralbert commented at 1:12 PM on August 19, 2026: contributor

    Current tests only check which binary is invoked via exec; the wrapper's own argument parsing is not tested. Five branches return without calling exec, and none of them are covered by tests.

    src/bitcoin.cpp is absent from the coverage report when running the existing test suite. With these tests, it reaches 47.1% coverage (48 of 102 lines). exec replaces the current process before the coverage counters are flushed to disk, so those execution paths do not appear in the coverage report. Running without a command returns a non-zero exit code, but this behavior is not covered by any test.

  2. test: add coverage for bitcoin wrapper argument handling
    The bitcoin wrapper's own argument handling is not exercised by any test.
    tool_bitcoin.py only checks which binary gets exec'd, so the paths that
    return without exec - version, help, no command, unknown command and
    unknown option - are never run.
    
    Add checks for those five cases.
    aed6402ac0
  3. DrahtBot added the label Tests on Aug 19, 2026
  4. DrahtBot commented at 1:12 PM on August 19, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. in test/functional/tool_bitcoin.py:66 in aed6402ac0
      60 | @@ -60,9 +61,58 @@ def test_args(self, cmd_args, node_args, expect_exe=None, expect_error=None):
      61 |              except Exception as e:
      62 |                  raise RuntimeError(f"Unexpected output from {node.args + extra_args}: {out=!r} {err=!r} {ret=!r}") from e
      63 |  
      64 | +    def run_wrapper(self, *args):
      65 | +        """Run the bitcoin wrapper directly and return (returncode, stdout, stderr)."""
      66 | +        result = subprocess.run([self.nodes[0].binaries.paths.bitcoin_bin, *args],
    


    mercie-ux commented at 10:48 AM on August 20, 2026:

    run_wrapper calls bitcoin_bin directly, bypassing node.binaries.valgrind_cmd that set_cmd_args already uses. So test_version/test_help/test_no_command/test_unrecognized never run under valgrind, even when using the --valgrind passed to the test runner. suggested fix for this:

    result = subprocess.run([*self.nodes[0].binaries.valgrind_cmd, self.nodes[0].binaries.paths.bitcoin_bin, *args],
                            capture_output=True, text=True)
    

    I verified locally unpatched, these four tests finish in ~13ms total under --valgrind. with this change, they take ~2.5-7s each, in line with the other tests in this file that already go through valgrind_cmd.


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-08-21 04:51 UTC

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