Skip to content

Commit fc0caaf

Browse files
committed
test: Add "include mempool" flag to MiniWallet rescan_utxos
1 parent d0a909a commit fc0caaf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/functional/test_framework/wallet.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _bulk_tx(self, tx, target_weight):
119119
def get_balance(self):
120120
return sum(u['value'] for u in self._utxos)
121121

122-
def rescan_utxos(self):
122+
def rescan_utxos(self, *, include_mempool=True):
123123
"""Drop all utxos and rescan the utxo set"""
124124
self._utxos = []
125125
res = self._test_node.scantxoutset(action="start", scanobjects=[self.get_descriptor()])
@@ -132,6 +132,12 @@ def rescan_utxos(self):
132132
height=utxo["height"],
133133
coinbase=utxo["coinbase"],
134134
confirmations=res["height"] - utxo["height"] + 1))
135+
if include_mempool:
136+
mempool = self._test_node.getrawmempool(verbose=True)
137+
# Sort tx by ancestor count. See BlockAssembler::SortForBlock in src/node/miner.cpp
138+
sorted_mempool = sorted(mempool.items(), key=lambda item: (item[1]["ancestorcount"], int(item[0], 16)))
139+
for txid, _ in sorted_mempool:
140+
self.scan_tx(self._test_node.getrawtransaction(txid=txid, verbose=True))
135141

136142
def scan_tx(self, tx):
137143
"""Scan the tx and adjust the internal list of owned utxos"""

0 commit comments

Comments
 (0)