{
 "number": 36022,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36022",
 "title": "test: add coverage for bitcoin wrapper argument handling",
 "author": "cyb3ralbert",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-08-19T13:12:01Z",
 "updated_at": "2026-09-10T06:41:04Z",
 "age_days": 29,
 "draft": false,
 "labels": [
  "Tests"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "b244610a672fc7591297d3db5c63b15d1c3afb1f",
 "head_ref": "test-bitcoin-multitool-coverage",
 "head_repo": "cyb3ralbert/litecoin-cash",
 "head_history": [],
 "additions": 51,
 "deletions": 0,
 "changed_files": 1,
 "commit_count": 2,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": [
    {
     "number": 36190,
     "title": "test: Check bitcoin wrapper child exit status on windows",
     "author": "Bortlesboat"
    },
    {
     "number": 36106,
     "title": "bitcoin wrapper: respect CMAKE_INSTALL_BINDIR/LIBEXECDIR",
     "author": "ryanofsky"
    }
   ]
  }
 },
 "acks_parsed": {},
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "mercie-ux"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-08-24T07:45:51Z",
  "last_reviewer_activity": "2026-08-20T10:48:48Z",
  "last_reviewer": "mercie-ux",
  "author_silent_days": 24,
  "waiting_on_author_days": 0,
  "days_since_update": 7
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": [
   36190,
   36106
  ]
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "test/functional/tool_bitcoin.py"
 ],
 "body": "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.\n\n`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.",
 "commits": [
  {
   "sha": "aed6402ac04bebe5d7aef88d9d15a1297a0e83b8",
   "date": "2026-08-19T13:07:43Z",
   "message": "test: add coverage for bitcoin wrapper argument handling\n\nThe bitcoin wrapper's own argument handling is not exercised by any test.\ntool_bitcoin.py only checks which binary gets exec'd, so the paths that\nreturn without exec - version, help, no command, unknown command and\nunknown option - are never run.\n\nAdd checks for those five cases."
  },
  {
   "sha": "b244610a672fc7591297d3db5c63b15d1c3afb1f",
   "date": "2026-08-24T07:33:12Z",
   "message": "test: run bitcoin wrapper under valgrind_cmd in run_wrapper\n\nrun_wrapper invoked the bitcoin binary directly, bypassing the\nnode.binaries.valgrind_cmd prefix that set_cmd_args already applies.\nAs a result test_version, test_help, test_no_command and\ntest_unrecognized never ran under valgrind despite --valgrind being\npassed to the test runner.\n\nPrefix the subprocess call with valgrind_cmd, matching the other\ntests in this file.\n\nSuggested-by: mercie-ux"
  }
 ],
 "timeline": [
  {
   "t": "2026-08-20T10:48:48Z",
   "kind": "review_comment",
   "who": "mercie-ux",
   "assoc": "NONE",
   "path": "test/functional/tool_bitcoin.py",
   "commit": "aed6402ac04bebe5d7aef88d9d15a1297a0e83b8",
   "in_reply_to": null,
   "text": "`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.\nsuggested fix for this:\n\n```\nresult = subprocess.run([*self.nodes[0].binaries.valgrind_cmd, self.nodes[0].binaries.paths.bitcoin_bin, *args],\n                        capture_output=True, text=True)\n```\n\nI 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`."
  },
  {
   "t": "2026-08-24T07:45:51Z",
   "kind": "review_comment",
   "who": "cyb3ralbert",
   "assoc": "CONTRIBUTOR",
   "path": "test/functional/tool_bitcoin.py",
   "commit": "aed6402ac04bebe5d7aef88d9d15a1297a0e83b8",
   "in_reply_to": 3820834782,
   "text": "Good catch, thanks \u2014 pushed a fix using `valgrind_cmd`, matching the rest of the file.\n\nFor context, `native_valgrind` doesn't run in PR CI (maintainers trigger it separately). When it does run, it uses binary substitution (`wrap-valgrind.py`) rather than the framework's `valgrind_cmd`, so a direct `subprocess.run([bin_path, ...])` there already runs under Valgrind. This gap therefore only affected the local `test_runner.py --valgrind` path.\n\nReran locally to confirm: unpatched, the four tests take ~28ms combined; with the fix, `test_version`/`test_help` take ~1.5\u20131.9s each and `test_no_command`/`test_unrecognized` ~0.7\u20131.3s each \u2014 in line with what you reported and with the other tests in this file that already go through `valgrind_cmd`."
  }
 ],
 "labels_log": [
  {
   "t": "2026-08-19T13:12:05Z",
   "action": "labeled",
   "label": "Tests",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 2882,
 "text_tokens_estimate": 720,
 "changed_paths": [
  "test/functional/tool_bitcoin.py"
 ],
 "files": [
  {
   "path": "test/functional/tool_bitcoin.py",
   "add": 51,
   "del": 0
  }
 ],
 "test_lines": 51,
 "git": {
  "head": "b244610a672fc7591297d3db5c63b15d1c3afb1f",
  "head_matches_backup": true,
  "base": "f72537037d3350e2974efd760eaa7b04f820880c",
  "commits": [
   {
    "sha": "aed6402ac0",
    "subject": "test: add coverage for bitcoin wrapper argument handling",
    "files": 1,
    "add": 50,
    "del": 0
   },
   {
    "sha": "b244610a67",
    "subject": "test: run bitcoin wrapper under valgrind_cmd in run_wrapper",
    "files": 1,
    "add": 2,
    "del": 1
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "a9df184f4ddeef94",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}