Skip to content

Commit faf4315

Browse files
author
MarcoFalke
committed
test: Return dict in MiniWallet::send_to
1 parent 9d85c03 commit faf4315

8 files changed

+20
-16
lines changed

Diff for: test/functional/feature_coinstatsindex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ def _test_coin_stats_index(self):
145145
self.block_sanity_check(res5['block_info'])
146146

147147
# Generate and send a normal tx with two outputs
148-
tx1_txid, tx1_vout = self.wallet.send_to(
148+
tx1 = self.wallet.send_to(
149149
from_node=node,
150150
scriptPubKey=self.wallet.get_scriptPubKey(),
151151
amount=21 * COIN,
152152
)
153153

154154
# Find the right position of the 21 BTC output
155-
tx1_out_21 = self.wallet.get_utxo(txid=tx1_txid, vout=tx1_vout)
155+
tx1_out_21 = self.wallet.get_utxo(txid=tx1["txid"], vout=tx1["sent_vout"])
156156

157157
# Generate and send another tx with an OP_RETURN output (which is unspendable)
158158
tx2 = self.wallet.create_self_transfer(utxo_to_spend=tx1_out_21)['tx']

Diff for: test/functional/feature_rbf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def make_utxo(self, node, amount, *, confirmed=True, scriptPubKey=None):
9393
confirmed - txout created will be confirmed in the blockchain;
9494
unconfirmed otherwise.
9595
"""
96-
txid, n = self.wallet.send_to(from_node=node, scriptPubKey=scriptPubKey or self.wallet.get_scriptPubKey(), amount=amount)
96+
tx = self.wallet.send_to(from_node=node, scriptPubKey=scriptPubKey or self.wallet.get_scriptPubKey(), amount=amount)
9797

9898
if confirmed:
9999
mempool_size = len(node.getrawmempool())
@@ -105,7 +105,7 @@ def make_utxo(self, node, amount, *, confirmed=True, scriptPubKey=None):
105105
assert new_size < mempool_size
106106
mempool_size = new_size
107107

108-
return self.wallet.get_utxo(txid=txid, vout=n)
108+
return self.wallet.get_utxo(txid=tx["txid"], vout=tx["sent_vout"])
109109

110110
def test_simple_doublespend(self):
111111
"""Simple doublespend"""

Diff for: test/functional/interface_rest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def run_test(self):
9696
self.wallet = MiniWallet(self.nodes[0])
9797

9898
self.log.info("Broadcast test transaction and sync nodes")
99-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))
99+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"]
100100
self.sync_all()
101101

102102
self.log.info("Test the /tx URI")
@@ -173,7 +173,7 @@ def run_test(self):
173173
# found with or without /checkmempool.
174174

175175
# do a tx and don't sync
176-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))
176+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"]
177177
json_obj = self.test_rest_request(f"/tx/{txid}")
178178
# get the spent output to later check for utxo (should be spent by then)
179179
spent = (json_obj['vin'][0]['txid'], json_obj['vin'][0]['vout'])

Diff for: test/functional/mempool_accept.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def run_test(self):
350350

351351
self.log.info('A tiny transaction(in non-witness bytes) that is disallowed')
352352
tx = CTransaction()
353-
tx.vin.append(CTxIn(COutPoint(int(seed_tx[0], 16), seed_tx[1]), b"", SEQUENCE_FINAL))
353+
tx.vin.append(CTxIn(COutPoint(int(seed_tx["txid"], 16), seed_tx["sent_vout"]), b"", SEQUENCE_FINAL))
354354
tx.wit.vtxinwit = [CTxInWitness()]
355355
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
356356
tx.vout.append(CTxOut(0, CScript([OP_RETURN] + ([OP_0] * (MIN_PADDING - 2)))))

Diff for: test/functional/mempool_sigoplimit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ def create_p2wsh_spending_tx(self, witness_script, output_script):
4949
"""Create a 1-input-1-output P2WSH spending transaction with only the
5050
witness script in the witness stack and the given output script."""
5151
# create P2WSH address and fund it via MiniWallet first
52-
txid, vout = self.wallet.send_to(
52+
fund = self.wallet.send_to(
5353
from_node=self.nodes[0],
5454
scriptPubKey=script_to_p2wsh_script(witness_script),
5555
amount=1000000,
5656
)
5757

5858
# create spending transaction
5959
tx = CTransaction()
60-
tx.vin = [CTxIn(COutPoint(int(txid, 16), vout))]
60+
tx.vin = [CTxIn(COutPoint(int(fund["txid"], 16), fund["sent_vout"]))]
6161
tx.wit.vtxinwit = [CTxInWitness()]
6262
tx.wit.vtxinwit[0].scriptWitness.stack = [bytes(witness_script)]
6363
tx.vout = [CTxOut(500000, output_script)]

Diff for: test/functional/p2p_filter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_msg_mempool(self):
136136
filter_peer = P2PBloomFilter()
137137

138138
self.log.debug("Create a tx relevant to the peer before connecting")
139-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)
139+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)["txid"]
140140

141141
self.log.debug("Send a mempool msg after connecting and check that the tx is received")
142142
self.nodes[0].add_p2p_connection(filter_peer)
@@ -183,14 +183,14 @@ def test_filter(self, filter_peer):
183183

184184
self.log.info('Check that we receive a tx if the filter matches a mempool tx')
185185
filter_peer.merkleblock_received = False
186-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)
186+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=filter_peer.watch_script_pubkey, amount=9 * COIN)["txid"]
187187
filter_peer.wait_for_tx(txid)
188188
assert not filter_peer.merkleblock_received
189189

190190
self.log.info('Check that after deleting filter all txs get relayed again')
191191
filter_peer.send_and_ping(msg_filterclear())
192192
for _ in range(5):
193-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=7 * COIN)
193+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=7 * COIN)["txid"]
194194
filter_peer.wait_for_tx(txid)
195195

196196
self.log.info('Check that request for filtered blocks is ignored if no filter is set')

Diff for: test/functional/rpc_createmultisig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def do_multisig(self):
195195
wmulti.unloadwallet()
196196

197197
spk = address_to_scriptpubkey(madd)
198-
txid, _ = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)
198+
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)["txid"]
199199
tx = node0.getrawtransaction(txid, True)
200200
vout = [v["n"] for v in tx["vout"] if madd == v["scriptPubKey"]["address"]]
201201
assert len(vout) == 1

Diff for: test/functional/test_framework/wallet.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,19 @@ def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
256256
Note that this method fails if there is no single internal utxo
257257
available that can cover the cost for the amount and the fixed fee
258258
(the utxo with the largest value is taken).
259-
260-
Returns a tuple (txid, n) referring to the created external utxo outpoint.
261259
"""
262260
tx = self.create_self_transfer(fee_rate=0)["tx"]
263261
assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee)
264262
tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet
265263
tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned
266264
txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex())
267-
return txid, 1
265+
return {
266+
"sent_vout": 1,
267+
"txid": txid,
268+
"wtxid": tx.getwtxid(),
269+
"hex": tx.serialize().hex(),
270+
"tx": tx,
271+
}
268272

269273
def send_self_transfer_multi(self, *, from_node, **kwargs):
270274
"""Call create_self_transfer_multi and send the transaction."""

0 commit comments

Comments
 (0)