Commit message · merge-scriptMerge bitcoin/bitcoin#36686: test: cover cumulative input value range in CheckTxInput tests.
98f9eb6afdfd2bb1cd2872bd7d2eb439ec2043a1 test: cover negative input in CheckTxInputs (KY-U)
133714d1695bc40277b213afd252c3e320cac73e test: cover cumulative input value range in CheckTxInputs (KY-U)
f8c6cd84e08043f206ca338d0ba7e4dc8bef5214 test: support multiple inputs in CheckTxInputs test helper (KY-U)
Pull request description:
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.
```diff
--- a/src/consensus/tx_verify.cpp
+++ b/src/consensus/tx_verify.cpp
@@ -189,7 +189,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,
// Check for negative or overflow input values
nValueIn += coin.out.nValue;
- if (!MoneyRange(coin.out.nValue) || !MoneyRange(nValueIn)) {
+ if (!MoneyRange(coin.out.nValue) && !MoneyRange(nValueIn)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-inputvalues-outofrange");
}
}
```
https://github.com/bitcoin/bitcoin/pull/36686/commits/f8c6cd84e08043f206ca338d0ba7e4dc8bef5214 adds support for multiple inputs in the test helper.
https://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.
https://github.com/bitcoin/bitcoin/pull/36686/commits/98f9eb6afdfd2bb1cd2872bd7d2eb439ec2043a1 adds a test for uncovered negative input case.
ACKs for top commit:
mercie-ux:
reACK 98f9eb6afdfd2bb1cd2872bd7d2eb439ec2043a1
ViniciusCestarii:
ACK 98f9eb6afdfd2bb1cd2872bd7d2eb439ec2043a1 nice!
sedited:
ACK 98f9eb6afdfd2bb1cd2872bd7d2eb439ec2043a1
Tree-SHA512: 1199a03bcc85ee56317f0d3089c03a3dd3116868630174c0ee26523c9e6d86370065e830a476e1c573b2504e5c45487c77d50e25e64f2e20e7c1dadaa12eb2b4
96/100 · StrongMessage clarity
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
Why it was queuedmemory safetyconsensus or confidential-proof validationsigning or wallet pathmerge-commit duplicate discount
AI analysis · Informational 14/100This commit only adds new test cases to Bitcoin Core's test suite. It does not change any production consensus, validation, or networking code. The tests verify that an existing check in the transaction validation logic correctly rejects transactions with out-of-range input values, including cases with multiple inputs. There is no security vulnerability being fixed here—only test coverage is being improved.