aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorMiles Liu <miles@bung.cc>2022-12-15 22:50:51 +0800
committerMiles Liu <miles@bung.cc>2023-01-06 09:52:39 +0800
commitfc0caaf4aa3d4b26a8673cca48df1a4f0b964a59 (patch)
treeb10a59483ae8b5790db4a0fc1091ba19a78731f4 /test/functional/test_framework
parentd0a909ae54a34ecd925c9d5064d530eaeeba46eb (diff)
test: Add "include mempool" flag to MiniWallet rescan_utxos
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r--test/functional/test_framework/wallet.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 2b4aa2bf5c..5dacf9d8d2 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -119,7 +119,7 @@ class MiniWallet:
def get_balance(self):
return sum(u['value'] for u in self._utxos)
- def rescan_utxos(self):
+ def rescan_utxos(self, *, include_mempool=True):
"""Drop all utxos and rescan the utxo set"""
self._utxos = []
res = self._test_node.scantxoutset(action="start", scanobjects=[self.get_descriptor()])
@@ -132,6 +132,12 @@ class MiniWallet:
height=utxo["height"],
coinbase=utxo["coinbase"],
confirmations=res["height"] - utxo["height"] + 1))
+ if include_mempool:
+ mempool = self._test_node.getrawmempool(verbose=True)
+ # Sort tx by ancestor count. See BlockAssembler::SortForBlock in src/node/miner.cpp
+ sorted_mempool = sorted(mempool.items(), key=lambda item: (item[1]["ancestorcount"], int(item[0], 16)))
+ for txid, _ in sorted_mempool:
+ self.scan_tx(self._test_node.getrawtransaction(txid=txid, verbose=True))
def scan_tx(self, tx):
"""Scan the tx and adjust the internal list of owned utxos"""