aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormerge-script <fanquake@gmail.com>2024-09-26 16:37:02 +0100
committermerge-script <fanquake@gmail.com>2024-09-26 16:37:02 +0100
commitfa7c2838a5f3693c6831b29a9c849a66506d1663 (patch)
tree95568e36dd49c050a773520167cef227f233755c /test
parentd5af7d28f475c0e579629a9b432c2b8a35075048 (diff)
parentfaf801515f8fcd11a3454105cab66c38f6f240fe (diff)
Merge bitcoin/bitcoin#30948: test: Add missing sync_mempools() to fill_mempool()
faf801515f8fcd11a3454105cab66c38f6f240fe test: Add missing sync_mempools() to fill_mempool() (MarcoFalke) fa48be6f0233cfbd5c1eab7b832c913912062fa5 test: Refactor fill_mempool to extract send_batch helper (MarcoFalke) Pull request description: Not doing the sync will lead to (intermittent) issues, as explained in https://github.com/bitcoin/bitcoin/issues/30922#issuecomment-2364529013. Fix all issues by doing the sync by default and disable it in places that do not need the sync. Fixes #30922 ACKs for top commit: mzumsande: Tested ACK faf801515f8fcd11a3454105cab66c38f6f240fe ismaelsadeeq: Tested ACK faf801515f8fcd11a3454105cab66c38f6f240fe marcofleon: Tested ACK faf801515f8fcd11a3454105cab66c38f6f240fe Tree-SHA512: 2de62d168cbb6857a9fb8bc12c42a9093fedf5e9beb6f83a32b3fa72a5ba3cf03631055fd25ef553399a27a6fe0d71c44cfe60660a4d31986debd13b8ab00228
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/mempool_package_rbf.py2
-rwxr-xr-xtest/functional/p2p_1p1c_network.py3
-rwxr-xr-xtest/functional/p2p_tx_download.py2
-rw-r--r--test/functional/test_framework/mempool_util.py26
4 files changed, 17 insertions, 16 deletions
diff --git a/test/functional/mempool_package_rbf.py b/test/functional/mempool_package_rbf.py
index f4d57262f2..a5b8fa5f87 100755
--- a/test/functional/mempool_package_rbf.py
+++ b/test/functional/mempool_package_rbf.py
@@ -554,7 +554,7 @@ class PackageRBFTest(BitcoinTestFramework):
self.generate(node, 1)
def test_child_conflicts_parent_mempool_ancestor(self):
- fill_mempool(self, self.nodes[0])
+ fill_mempool(self, self.nodes[0], tx_sync_fun=self.no_op)
# Reset coins since we filled the mempool with current coins
self.coins = self.wallet.get_utxos(mark_as_spent=False, confirmed_only=True)
diff --git a/test/functional/p2p_1p1c_network.py b/test/functional/p2p_1p1c_network.py
index f9e782f524..cdc4e1691d 100755
--- a/test/functional/p2p_1p1c_network.py
+++ b/test/functional/p2p_1p1c_network.py
@@ -49,9 +49,6 @@ class PackageRelayTest(BitcoinTestFramework):
def raise_network_minfee(self):
fill_mempool(self, self.nodes[0])
- self.log.debug("Wait for the network to sync mempools")
- self.sync_mempools()
-
self.log.debug("Check that all nodes' mempool minimum feerates are above min relay feerate")
for node in self.nodes:
assert_equal(node.getmempoolinfo()['minrelaytxfee'], FEERATE_1SAT_VB)
diff --git a/test/functional/p2p_tx_download.py b/test/functional/p2p_tx_download.py
index efad4e7c0f..c69d6ff405 100755
--- a/test/functional/p2p_tx_download.py
+++ b/test/functional/p2p_tx_download.py
@@ -250,7 +250,7 @@ class TxDownloadTest(BitcoinTestFramework):
def test_rejects_filter_reset(self):
self.log.info('Check that rejected tx is not requested again')
node = self.nodes[0]
- fill_mempool(self, node)
+ fill_mempool(self, node, tx_sync_fun=self.no_op)
self.wallet.rescan_utxos()
mempoolminfee = node.getmempoolinfo()['mempoolminfee']
peer = node.add_p2p_connection(TestP2PConn())
diff --git a/test/functional/test_framework/mempool_util.py b/test/functional/test_framework/mempool_util.py
index 148cc935ed..fe47123e13 100644
--- a/test/functional/test_framework/mempool_util.py
+++ b/test/functional/test_framework/mempool_util.py
@@ -19,14 +19,11 @@ from .wallet import (
)
-def fill_mempool(test_framework, node):
+def fill_mempool(test_framework, node, *, tx_sync_fun=None):
"""Fill mempool until eviction.
Allows for simpler testing of scenarios with floating mempoolminfee > minrelay
- Requires -datacarriersize=100000 and
- -maxmempool=5.
- It will not ensure mempools become synced as it
- is based on a single node and assumes -minrelaytxfee
+ Requires -datacarriersize=100000 and -maxmempool=5 and assumes -minrelaytxfee
is 1 sat/vbyte.
To avoid unintentional tx dependencies, the mempool filling txs are created with a
tagged ephemeral miniwallet instance.
@@ -57,18 +54,25 @@ def fill_mempool(test_framework, node):
tx_to_be_evicted_id = ephemeral_miniwallet.send_self_transfer(
from_node=node, utxo_to_spend=confirmed_utxos.pop(0), fee_rate=relayfee)["txid"]
+ def send_batch(fee):
+ utxos = confirmed_utxos[:tx_batch_size]
+ create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
+ del confirmed_utxos[:tx_batch_size]
+
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
# by 130 should result in a fee that corresponds to 2x of that fee rate
base_fee = relayfee * 130
+ batch_fees = [(i + 1) * base_fee for i in range(num_of_batches)]
test_framework.log.debug("Fill up the mempool with txs with higher fee rate")
- with node.assert_debug_log(["rolling minimum fee bumped"]):
- for batch_of_txid in range(num_of_batches):
- fee = (batch_of_txid + 1) * base_fee
- utxos = confirmed_utxos[:tx_batch_size]
- create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
- del confirmed_utxos[:tx_batch_size]
+ for fee in batch_fees[:-3]:
+ send_batch(fee)
+ tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync before any eviction
+ assert_equal(node.getmempoolinfo()["mempoolminfee"], Decimal("0.00001000"))
+ for fee in batch_fees[-3:]:
+ send_batch(fee)
+ tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync after all evictions
test_framework.log.debug("The tx should be evicted by now")
# The number of transactions created should be greater than the ones present in the mempool