Browse Source

Merge #12133: [qa] Fix rare failure in p2p-segwit.py

35c2b1f Fix rare failure in p2p-segwit.py (Suhas Daftuar)

Pull request description:

  Avoid creating very small utxos that would violate an assumption in
  test_non_standard_witness.

  Fixes #11953

Tree-SHA512: 5fb7ae68f8731df819bab365923a84568b57227e4112f711fc2574767d15be83acd3e99d0d5bac94a42411a958b13a2119468babefed14efcfdda180004d4166
0.16
Wladimir J. van der Laan 7 years ago
parent
commit
1d2eaba300
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 14
      test/functional/p2p-segwit.py

14
test/functional/p2p-segwit.py

@ -1396,18 +1396,20 @@ class SegWitTest(BitcoinTestFramework):
temp_utxos.pop(0) temp_utxos.pop(0)
# Update self.utxos for later tests. Just spend everything in # Update self.utxos for later tests by creating two outputs
# temp_utxos to a corresponding entry in self.utxos # that consolidate all the coins in temp_utxos.
output_value = sum(i.nValue for i in temp_utxos) // 2
tx = CTransaction() tx = CTransaction()
index = 0 index = 0
for i in temp_utxos:
# Just spend to our usual anyone-can-spend output # Just spend to our usual anyone-can-spend output
# Use SIGHASH_SINGLE|SIGHASH_ANYONECANPAY so we can build up tx.vout = [CTxOut(output_value, CScript([OP_TRUE]))] * 2
for i in temp_utxos:
# Use SIGHASH_ALL|SIGHASH_ANYONECANPAY so we can build up
# the signatures as we go. # the signatures as we go.
tx.vin.append(CTxIn(COutPoint(i.sha256, i.n), b"")) tx.vin.append(CTxIn(COutPoint(i.sha256, i.n), b""))
tx.vout.append(CTxOut(i.nValue, CScript([OP_TRUE])))
tx.wit.vtxinwit.append(CTxInWitness()) tx.wit.vtxinwit.append(CTxInWitness())
sign_P2PK_witness_input(witness_program, tx, index, SIGHASH_SINGLE|SIGHASH_ANYONECANPAY, i.nValue, key) sign_P2PK_witness_input(witness_program, tx, index, SIGHASH_ALL|SIGHASH_ANYONECANPAY, i.nValue, key)
index += 1 index += 1
block = self.build_next_block() block = self.build_next_block()
self.update_witness_block_with_transactions(block, [tx]) self.update_witness_block_with_transactions(block, [tx])

Loading…
Cancel
Save