{
 "number": 36686,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36686",
 "title": "test: cover cumulative input value range in CheckTxInput tests.",
 "author": "KY-U",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-10-28T17:45:15Z",
 "updated_at": "2026-11-01T09:06:25Z",
 "description_hash": "be2d344d154e53d9",
 "age_days": 4,
 "draft": false,
 "labels": [
  "Tests"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "133714d1695bc40277b213afd252c3e320cac73e",
 "head_ref": "2026-10-checktxinputs",
 "head_repo": "KY-U/bitcoin",
 "head_history": [
  {
   "t": "2026-10-28T18:15:09Z",
   "sha": "5d93087c6abbda758baf3d49c552e6dc259d5021"
  },
  {
   "t": "2026-10-29T15:06:41Z",
   "sha": "133714d1695bc40277b213afd252c3e320cac73e"
  }
 ],
 "additions": 18,
 "deletions": 9,
 "changed_files": 1,
 "commit_count": 2,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "ack": [
     {
      "login": "mercie-ux",
      "url": "https://github.com/bitcoin/bitcoin/pull/36686#pullrequestreview-5727312289"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "mercie-ux": {
   "kind": "ack",
   "hash": "133714d1695bc40277b213afd252c3e320cac73e",
   "t": "2026-11-01T09:06:21Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 1,
  "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": [
   "ValeraFinebits",
   "mercie-ux"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-29T15:14:53Z",
  "last_reviewer_activity": "2026-11-01T09:06:21Z",
  "last_reviewer": "mercie-ux",
  "author_silent_days": 3,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/test/transaction_tests.cpp"
 ],
 "body": "In `Consensus::CheckTxInputs`, the inputs are invalid if, for every input coin, either `coin.out.nValue` or `nValueIn` is out of range. However, the current `checktxinputs_invalid_transactions_test` only covers cases with one input, so the sum `nValueIn` is always equal to `coin.out.nValue`, leaving the [following mutant](https://mutanthub.space/mutants/275) alive.\n```diff\n--- a/src/consensus/tx_verify.cpp\n+++ b/src/consensus/tx_verify.cpp\n@@ -189,7 +189,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,\n\n         // Check for negative or overflow input values\n         nValueIn += coin.out.nValue;\n-        if (!MoneyRange(coin.out.nValue) || !MoneyRange(nValueIn)) {\n+        if (!MoneyRange(coin.out.nValue) && !MoneyRange(nValueIn)) {\n             return state.Invalid(TxValidationResult::TX_CONSENSUS, \"bad-txns-inputvalues-outofrange\");\n         }\n     }\n```\nhttps://github.com/bitcoin/bitcoin/pull/36686/commits/f8c6cd84e08043f206ca338d0ba7e4dc8bef5214 adds support for multiple inputs in the test helper.\n\nhttps://github.com/bitcoin/bitcoin/pull/36686/commits/133714d1695bc40277b213afd252c3e320cac73e adds a test case with multiple valid inputs, whose sum exceed `MAX_MONEY`, while also having `nValueIn` != `coin.out.nValue`, killing the mutant.",
 "commits": [
  {
   "sha": "f8c6cd84e08043f206ca338d0ba7e4dc8bef5214",
   "date": "2026-10-28T18:12:31Z",
   "message": "test: support multiple inputs in CheckTxInputs test helper\n\nAccept a list of input values and create a distinct coin and prevout for each one. Keep the existing test cases as single-input transactions with no change in behaviour."
  },
  {
   "sha": "133714d1695bc40277b213afd252c3e320cac73e",
   "date": "2026-10-29T15:04:49Z",
   "message": "test: cover cumulative input value range in CheckTxInputs\n\nAdd invalid test case with two inputs that are individually within range, but exceed MAX_MONEY when summed."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-28T18:15:09Z",
   "kind": "force_push",
   "who": "KY-U",
   "commit": "5d93087c6abbda758baf3d49c552e6dc259d5021",
   "id": "push:5d93087c6abbda758baf3d49c552e6dc259d5021"
  },
  {
   "t": "2026-10-29T13:30:23Z",
   "kind": "review_comment",
   "who": "ValeraFinebits",
   "assoc": "NONE",
   "path": "src/test/transaction_tests.cpp",
   "commit": "5d93087c6abbda758baf3d49c552e6dc259d5021",
   "in_reply_to": null,
   "text": "Optional: use `output_value = 1` here so the `||` -> `&&` mutant passes the fee check and incorrectly returns `true`. The current case already catches the mutant via the reject reason, this would catch erroneous acceptance directly.\n\n```suggestion\n                  /*output_value=*/1,\n```",
   "id": "rc:4412916786",
   "url": "https://github.com/bitcoin/bitcoin/pull/36686#discussion_r4412916786",
   "hash": "214260f579c4c78a",
   "edited": null
  },
  {
   "t": "2026-10-29T13:35:08Z",
   "kind": "review_comment",
   "who": "ValeraFinebits",
   "assoc": "NONE",
   "path": "src/test/transaction_tests.cpp",
   "commit": "5d93087c6abbda758baf3d49c552e6dc259d5021",
   "in_reply_to": 4412916786,
   "text": "Or we could keep the zero-output case and add another with `output_value = 1`. The existing case also checks that the input value error takes precedence over the fee error.",
   "id": "rc:4412967818",
   "url": "https://github.com/bitcoin/bitcoin/pull/36686#discussion_r4412967818",
   "hash": "014150333b13f886",
   "edited": null
  },
  {
   "t": "2026-10-29T15:06:41Z",
   "kind": "force_push",
   "who": "KY-U",
   "commit": "133714d1695bc40277b213afd252c3e320cac73e",
   "id": "push:133714d1695bc40277b213afd252c3e320cac73e"
  },
  {
   "t": "2026-10-29T15:14:53Z",
   "kind": "review_comment",
   "who": "KY-U",
   "assoc": "CONTRIBUTOR",
   "path": "src/test/transaction_tests.cpp",
   "commit": "5d93087c6abbda758baf3d49c552e6dc259d5021",
   "in_reply_to": 4412916786,
   "text": "Changed the output value to 1 as suggested in the first comment. I'd prefer to change the existing case rather than add another one. That way we keep new test cases to a minimum while exercising the erroneous acceptance and killing the mutant. Thanks for the suggestions!",
   "id": "rc:4414167199",
   "url": "https://github.com/bitcoin/bitcoin/pull/36686#discussion_r4414167199",
   "hash": "6957fc8332352a9a",
   "edited": "2026-10-30T17:11:45Z"
  },
  {
   "t": "2026-11-01T09:05:27Z",
   "kind": "review_comment",
   "who": "mercie-ux",
   "assoc": "CONTRIBUTOR",
   "path": "src/test/transaction_tests.cpp",
   "commit": "133714d1695bc40277b213afd252c3e320cac73e",
   "in_reply_to": null,
   "text": "```cpp\n    check_invalid(/*input_values=*/{2 * COIN, -1 * COIN},\n                  /*output_value=*/1,\n                  /*coinbase=*/false,\n                  /*spend_height=*/2,\n                  TxValidationResult::TX_CONSENSUS, /*expected_reason=*/\"bad-txns-inputvalues-outofrange\");\n```\nCould add a case for the per-coin check too, removing it currently doesn't break any test.",
   "id": "rc:4434999674",
   "url": "https://github.com/bitcoin/bitcoin/pull/36686#discussion_r4434999674",
   "hash": "f914a8ee19b52cc7",
   "edited": "2026-11-01T09:06:21Z"
  },
  {
   "t": "2026-11-01T09:06:21Z",
   "kind": "review",
   "who": "mercie-ux",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "133714d1695bc40277b213afd252c3e320cac73e",
   "text": "ACK 133714d1695bc40277b213afd252c3e320cac73e\n\nVerified the mutant is killed. I have left an optional suggestion for the per-coin check, which is still uncovered.",
   "id": "r:5727312289",
   "url": "https://github.com/bitcoin/bitcoin/pull/36686#pullrequestreview-5727312289",
   "hash": "f403a7f57a918958",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-28T17:45:20Z",
   "action": "labeled",
   "label": "Tests",
   "who": "DrahtBot"
  },
  {
   "t": "2026-10-28T18:16:01Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-10-28T19:19:59Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 3035,
 "text_tokens_estimate": 758,
 "changed_paths": [
  "src/test/transaction_tests.cpp"
 ],
 "files": [
  {
   "path": "src/test/transaction_tests.cpp",
   "add": 18,
   "del": 9
  }
 ],
 "test_lines": 27,
 "git": {
  "head": "133714d1695bc40277b213afd252c3e320cac73e",
  "head_matches_backup": true,
  "base": "0f27bed5b2924420d65caeca439e6b036d3c6cb2",
  "patch_id": "5243d6355ea21a6a",
  "commits": [
   {
    "sha": "f8c6cd84e0",
    "subject": "test: support multiple inputs in CheckTxInputs test helper",
    "files": 1,
    "add": 12,
    "del": 9
   },
   {
    "sha": "133714d169",
    "subject": "test: cover cumulative input value range in CheckTxInputs",
    "files": 1,
    "add": 6,
    "del": 0
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "5243d6355ea21a6a",
 "input_hash": "4df97a401f3c78f8",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}