Skip to content

Commit 35c2b1f

Browse files
committed
Fix rare failure in p2p-segwit.py
Avoid creating very small utxos that would violate an assumption in test_non_standard_witness.
1 parent 5691028 commit 35c2b1f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/functional/p2p-segwit.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,18 +1396,20 @@ def test_signature_version_1(self):
13961396

13971397
temp_utxos.pop(0)
13981398

1399-
# Update self.utxos for later tests. Just spend everything in
1400-
# temp_utxos to a corresponding entry in self.utxos
1399+
# Update self.utxos for later tests by creating two outputs
1400+
# that consolidate all the coins in temp_utxos.
1401+
output_value = sum(i.nValue for i in temp_utxos) // 2
1402+
14011403
tx = CTransaction()
14021404
index = 0
1405+
# Just spend to our usual anyone-can-spend output
1406+
tx.vout = [CTxOut(output_value, CScript([OP_TRUE]))] * 2
14031407
for i in temp_utxos:
1404-
# Just spend to our usual anyone-can-spend output
1405-
# Use SIGHASH_SINGLE|SIGHASH_ANYONECANPAY so we can build up
1408+
# Use SIGHASH_ALL|SIGHASH_ANYONECANPAY so we can build up
14061409
# the signatures as we go.
14071410
tx.vin.append(CTxIn(COutPoint(i.sha256, i.n), b""))
1408-
tx.vout.append(CTxOut(i.nValue, CScript([OP_TRUE])))
14091411
tx.wit.vtxinwit.append(CTxInWitness())
1410-
sign_P2PK_witness_input(witness_program, tx, index, SIGHASH_SINGLE|SIGHASH_ANYONECANPAY, i.nValue, key)
1412+
sign_P2PK_witness_input(witness_program, tx, index, SIGHASH_ALL|SIGHASH_ANYONECANPAY, i.nValue, key)
14111413
index += 1
14121414
block = self.build_next_block()
14131415
self.update_witness_block_with_transactions(block, [tx])

0 commit comments

Comments
 (0)