What changed, and why it matters
This commit only changes a test file. It updates how one test case sets up its test data to match a previous code change, based on a review suggestion. There is no change to the actual application code that users run, so it does not create or fix a security issue in the product itself.
No security action needed. Treat as normal test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/test_psbt_parser.py. It replaces a test helper that used mocking (patching PSBTParser._verify_input_amounts) with a more realistic test setup that constructs a valid non_witness_utxo for a p2pk output and updates the input txid accordingly. The test still asserts that parsing raises ‘Unsupported policy type’. This is a test-quality/refactoring change, not a functional code change.
Changed components
tests/test_psbt_parser.pyInspect captured patch +8 / −10
### tests/test_psbt_parser.py
@@ -2509,13 +2509,11 @@ def p2pk(public_key: PublicKey) -> script.Script:
assert psbt.inputs[0].witness_utxo.script_pubkey.script_type() is None
assert psbt.outputs[0].script_pubkey.script_type() is None
- # An unrecognized script type with no non_witness_utxo to prove its amount is
- # exactly what _verify_input_amounts() now refuses, and editing the
- # non_witness_utxo to pay to this p2pk script is not an option either: that
- # changes the txid it hashes to. So this psbt can no longer reach _parse_inputs on
- # its own; see test_unrecognized_script_type_without_non_witness_utxo_raises for
- # that rejection. The catch-all safety check is still worth asserting, so stub out
- # the amount verification that now precedes it.
- with patch.object(PSBTParser, "_verify_input_amounts"):
- with pytest.raises(RuntimeError, match="Unsupported policy type"):
- self._parse(psbt)
+ # The parse verifies input amounts before the scriptPubKey rebuild, so give this
+ # p2pk coin a matching non_witness_utxo and point the input at its new txid.
+ inp = psbt.inputs[0]
+ inp.non_witness_utxo.vout[inp.vout].script_pubkey = inp.witness_utxo.script_pubkey
+ inp.txid = inp.non_witness_utxo.txid()
+
+ with pytest.raises(RuntimeError, match="Unsupported policy type"):
+ self._parse(psbt)Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.