Skip to content

Commit

Permalink
test: Add MiniWallet.sendrawtransaction
Browse files Browse the repository at this point in the history
Can be reviewed with --ignore-all-space --color-moved=dimmed-zebra
  • Loading branch information
MarcoFalke committed Apr 22, 2021
1 parent 4b5659c commit fa1bedb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/functional/test_framework/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ def scan_blocks(self, *, start=1, num):
for i in range(start, start + num):
block = self._test_node.getblock(blockhash=self._test_node.getblockhash(i), verbosity=2)
for tx in block['tx']:
for out in tx['vout']:
if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value']})
self.scan_tx(tx)

def scan_tx(self, tx):
"""Scan the tx for self._scriptPubKey outputs and add them to self._utxos"""
for out in tx['vout']:
if out['scriptPubKey']['hex'] == self._scriptPubKey.hex():
self._utxos.append({'txid': tx['txid'], 'vout': out['n'], 'value': out['value']})

def generate(self, num_blocks):
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
Expand Down Expand Up @@ -84,8 +88,11 @@ def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_sp
tx_hex = tx.serialize().hex()

tx_info = from_node.testmempoolaccept([tx_hex])[0]
self._utxos.append({'txid': tx_info['txid'], 'vout': 0, 'value': send_value})
from_node.sendrawtransaction(tx_hex)
self.sendrawtransaction(from_node=from_node, tx_hex=tx_hex)
assert_equal(tx_info['vsize'], vsize)
assert_equal(tx_info['fees']['base'], fee)
return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex}

def sendrawtransaction(self, *, from_node, tx_hex):
from_node.sendrawtransaction(tx_hex)
self.scan_tx(from_node.decoderawtransaction(tx_hex))

0 comments on commit fa1bedb

Please sign in to comment.