aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbrunoerg <brunoely.gc@gmail.com>2023-02-28 09:58:06 -0300
committerbrunoerg <brunoely.gc@gmail.com>2023-05-19 09:13:17 -0300
commit60ced9007d518d542ce489b91076f9bbaf3312e3 (patch)
tree991235f37a354572973a4d58c62a8589ae79516f /test
parent7be7e62fdf4623e0cc680ea8205750c16414453e (diff)
test: fix intermittent issue in `feature_bip68_sequence`
To avoid `bad-txns-premature-spend-of-coinbase` error, when getting a utxo (using `get_utxo`) to create a new transaction `get_utxo` shouldn't return by default immature coinbase.
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/mempool_compatibility.py2
-rwxr-xr-xtest/functional/mempool_persist.py1
-rw-r--r--test/functional/test_framework/wallet.py4
3 files changed, 5 insertions, 2 deletions
diff --git a/test/functional/mempool_compatibility.py b/test/functional/mempool_compatibility.py
index a7bdc49695..7337802aea 100755
--- a/test/functional/mempool_compatibility.py
+++ b/test/functional/mempool_compatibility.py
@@ -47,12 +47,12 @@ class MempoolCompatibilityTest(BitcoinTestFramework):
# unbroadcasted_tx won't pass old_node's `MemPoolAccept::PreChecks`.
self.connect_nodes(0, 1)
self.sync_blocks()
- self.stop_node(1)
self.log.info("Add a transaction to mempool on old node and shutdown")
old_tx_hash = new_wallet.send_self_transfer(from_node=old_node)["txid"]
assert old_tx_hash in old_node.getrawmempool()
self.stop_node(0)
+ self.stop_node(1)
self.log.info("Move mempool.dat from old to new node")
old_node_mempool = os.path.join(old_node.datadir, self.chain, 'mempool.dat')
diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py
index f818801136..8f74d9de20 100755
--- a/test/functional/mempool_persist.py
+++ b/test/functional/mempool_persist.py
@@ -191,6 +191,7 @@ class MempoolPersistTest(BitcoinTestFramework):
def test_persist_unbroadcast(self):
node0 = self.nodes[0]
self.start_node(0)
+ self.start_node(2)
# clear out mempool
self.generate(node0, 1, sync_fun=self.no_op)
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 64606b818b..90f7275b44 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -218,10 +218,12 @@ class MiniWallet:
txid: get the first utxo we find from a specific transaction
"""
self._utxos = sorted(self._utxos, key=lambda k: (k['value'], -k['height'])) # Put the largest utxo last
+ blocks_height = self._test_node.getblockchaininfo()['blocks']
+ mature_coins = list(filter(lambda utxo: not utxo['coinbase'] or COINBASE_MATURITY - 1 <= blocks_height - utxo['height'], self._utxos))
if txid:
utxo_filter: Any = filter(lambda utxo: txid == utxo['txid'], self._utxos)
else:
- utxo_filter = reversed(self._utxos) # By default the largest utxo
+ utxo_filter = reversed(mature_coins) # By default the largest utxo
if vout is not None:
utxo_filter = filter(lambda utxo: vout == utxo['vout'], utxo_filter)
index = self._utxos.index(next(utxo_filter))