diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2018-01-09 13:36:14 -0500 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2018-01-09 14:13:10 -0500 |
commit | 35c2b1fe3b1a046bbd1bfaf1c178e838d047277a (patch) | |
tree | 3df1756fc44213c3830302931a6ecb058b28b9df /test/functional/p2p-segwit.py | |
parent | 56910285fa4a7a0f3b931e7613b9691cee9c13ff (diff) |
Fix rare failure in p2p-segwit.py
Avoid creating very small utxos that would violate an assumption in
test_non_standard_witness.
Diffstat (limited to 'test/functional/p2p-segwit.py')
-rwxr-xr-x | test/functional/p2p-segwit.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/functional/p2p-segwit.py b/test/functional/p2p-segwit.py index 2487fdc239..31550cb76a 100755 --- a/test/functional/p2p-segwit.py +++ b/test/functional/p2p-segwit.py @@ -1396,18 +1396,20 @@ class SegWitTest(BitcoinTestFramework): temp_utxos.pop(0) - # Update self.utxos for later tests. Just spend everything in - # temp_utxos to a corresponding entry in self.utxos + # Update self.utxos for later tests by creating two outputs + # that consolidate all the coins in temp_utxos. + output_value = sum(i.nValue for i in temp_utxos) // 2 + tx = CTransaction() index = 0 + # Just spend to our usual anyone-can-spend output + tx.vout = [CTxOut(output_value, CScript([OP_TRUE]))] * 2 for i in temp_utxos: - # Just spend to our usual anyone-can-spend output - # Use SIGHASH_SINGLE|SIGHASH_ANYONECANPAY so we can build up + # Use SIGHASH_ALL|SIGHASH_ANYONECANPAY so we can build up # the signatures as we go. tx.vin.append(CTxIn(COutPoint(i.sha256, i.n), b"")) - tx.vout.append(CTxOut(i.nValue, CScript([OP_TRUE]))) 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 block = self.build_next_block() self.update_witness_block_with_transactions(block, [tx]) |