Skip to content

Commit fa13375

Browse files
author
MacroFake
committed
test: Sync MiniWallet utxo state after each generate call
1 parent dddd7c4 commit fa13375

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/functional/test_framework/wallet.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,16 @@ def sign_tx(self, tx, fixed_length=True):
147147
tx.rehash()
148148

149149
def generate(self, num_blocks, **kwargs):
150-
"""Generate blocks with coinbase outputs to the internal address, and append the outputs to the internal list"""
150+
"""Generate blocks with coinbase outputs to the internal address, and call rescan_utxos"""
151151
blocks = self._test_node.generatetodescriptor(num_blocks, self.get_descriptor(), **kwargs)
152-
for b in blocks:
153-
block_info = self._test_node.getblock(blockhash=b, verbosity=2)
154-
cb_tx = block_info['tx'][0]
155-
self._utxos.append(self._create_utxo(txid=cb_tx["txid"], vout=0, value=cb_tx["vout"][0]["value"], height=block_info["height"]))
152+
# Calling rescan_utxos here makes sure that after a generate the utxo
153+
# set is in a clean state. For example, the wallet will update
154+
# - if the caller consumed utxos, but never used them
155+
# - if the caller sent a transaction that is not mined or got rbf'd
156+
# - after block re-orgs
157+
# - the utxo height for mined mempool txs
158+
# - However, the wallet will not consider remaining mempool txs
159+
self.rescan_utxos()
156160
return blocks
157161

158162
def get_scriptPubKey(self):

0 commit comments

Comments
 (0)