Skip to content

Commit 4cad916

Browse files
author
MarcoFalke
committed
Merge #11869: QA: segwit.py: s/find_unspent/find_spendable_utxo/
9bb59cf QA: segwit.py: s/find_unspent/find_spendable_utxo/ (Jorge Timón) Pull request description: Separated from #8994 It was found out testing that PR but I think this fix should be done even without #8994 the fix is not necessary by luck. Unless I'm missing something. Tree-SHA512: ba1a970e674878ae2f27ee8bba372fa3b42dafff682374f50e5ddc9896fd8808fef2b2b70c7028f2a7b0dbea9f3e29a757e2cde98970f5761bf414455ba02c09
2 parents 1b06ed1 + 9bb59cf commit 4cad916

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/functional/feature_segwit.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ def getutxo(txid):
3030
utxo["txid"] = txid
3131
return utxo
3232

33-
def find_unspent(node, min_value):
34-
for utxo in node.listunspent():
35-
if utxo['amount'] >= min_value:
33+
def find_spendable_utxo(node, min_value):
34+
for utxo in node.listunspent(query_options={'minimumAmount': min_value}):
35+
if utxo['spendable']:
3636
return utxo
3737

38+
raise AssertionError("Unspent output equal or higher than %s not found" % min_value)
39+
3840
class SegWitTest(BitcoinTestFramework):
3941
def set_test_params(self):
4042
self.setup_clean_chain = True
@@ -113,8 +115,8 @@ def run_test(self):
113115
for i in range(5):
114116
for n in range(3):
115117
for v in range(2):
116-
wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_unspent(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999")))
117-
p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_unspent(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999")))
118+
wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999")))
119+
p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999")))
118120

119121
self.nodes[0].generate(1) #block 163
120122
sync_blocks(self.nodes)
@@ -209,7 +211,7 @@ def run_test(self):
209211
# tx2 (segwit input, paying to a non-segwit output) ->
210212
# tx3 (non-segwit input, paying to a non-segwit output).
211213
# tx1 is allowed to appear in the block, but no others.
212-
txid1 = send_to_witness(1, self.nodes[0], find_unspent(self.nodes[0], 50), self.pubkey[0], False, Decimal("49.996"))
214+
txid1 = send_to_witness(1, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[0], False, Decimal("49.996"))
213215
hex_tx = self.nodes[0].gettransaction(txid)['hex']
214216
tx = FromHex(CTransaction(), hex_tx)
215217
assert(tx.wit.is_null()) # This should not be a segwit input
@@ -570,7 +572,7 @@ def run_test(self):
570572
assert_equal(self.nodes[1].listtransactions("*", 1, 0, True)[0]["txid"], txid)
571573

572574
def mine_and_test_listunspent(self, script_list, ismine):
573-
utxo = find_unspent(self.nodes[0], 50)
575+
utxo = find_spendable_utxo(self.nodes[0], 50)
574576
tx = CTransaction()
575577
tx.vin.append(CTxIn(COutPoint(int('0x'+utxo['txid'],0), utxo['vout'])))
576578
for i in script_list:

0 commit comments

Comments
 (0)