test: check all inputs after joinpsbts in rpc_psbt.py
What changed, and why it matters
This commit fixes a flaky test in Bitcoin Core's own test suite. The test was checking only one of four joined transaction inputs for a specific property, but because the inputs are randomly shuffled, it only caught the right input about 25% of the time. The fix checks all four inputs instead. It is a test-only change with no effect on the Bitcoin Core software users run.
No security action needed. This is a test reliability improvement. Reviewers may optionally verify that the loop correctly covers the intended invariant.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/rpc_psbt.py, the test for joinpsbts previously asserted that inputs[3] lacked final_scriptwitness and final_scriptSig. Because joinpsbts shuffles inputs, this assertion only exercised the finalized input from psbt2 roughly one in four runs. The patch replaces the single-index check with a loop over all joined inputs, ensuring deterministic coverage of the requirement that joining drops final scripts.
Changed components
test/functional/rpc_psbt.pyInspect captured patch +4 / −2
### test/functional/rpc_psbt.py
@@ -1445,8 +1445,10 @@ def test_psbt_input_keys(psbt_input, keys):
joined_decoded = self.nodes[0].decodepsbt(joined)
assert_equal(len(joined_decoded['inputs']), 4)
assert_equal(len(joined_decoded['outputs']), 2)
- assert "final_scriptwitness" not in joined_decoded['inputs'][3]
- assert "final_scriptSig" not in joined_decoded['inputs'][3]
+ # joining must drop the final scripts of psbt2's input; inputs are shuffled, so check all
+ for joined_input in joined_decoded['inputs']:
+ assert "final_scriptwitness" not in joined_input
+ assert "final_scriptSig" not in joined_input
# Check that joining shuffles the inputs and outputs
# 10 attempts should be enough to get a shuffled joinWhy this scored 15/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.