mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-12 18:44:59 +01:00
test: ensure that fill_mempool
leaves some room in mempool
This commit is contained in:
parent
2ec0a28a37
commit
9c89fb4cc1
1 changed files with 12 additions and 3 deletions
|
@ -42,16 +42,17 @@ def fill_mempool(test_framework, node):
|
||||||
# Generate UTXOs to flood the mempool
|
# Generate UTXOs to flood the mempool
|
||||||
# 1 to create a tx initially that will be evicted from the mempool later
|
# 1 to create a tx initially that will be evicted from the mempool later
|
||||||
# 75 transactions each with a fee rate higher than the previous one
|
# 75 transactions each with a fee rate higher than the previous one
|
||||||
|
# 1 to create a final middle-sized tx to evict a filler tx and create room (if needed)
|
||||||
ephemeral_miniwallet = MiniWallet(node, tag_name="fill_mempool_ephemeral_wallet")
|
ephemeral_miniwallet = MiniWallet(node, tag_name="fill_mempool_ephemeral_wallet")
|
||||||
test_framework.generate(ephemeral_miniwallet, 1 + num_of_batches * tx_batch_size)
|
test_framework.generate(ephemeral_miniwallet, 2 + num_of_batches * tx_batch_size)
|
||||||
|
|
||||||
# Mine enough blocks so that the UTXOs are allowed to be spent
|
# Mine enough blocks so that the UTXOs are allowed to be spent
|
||||||
test_framework.generate(node, COINBASE_MATURITY - 1)
|
test_framework.generate(node, COINBASE_MATURITY - 1)
|
||||||
|
|
||||||
# Get all UTXOs up front to ensure none of the transactions spend from each other, as that may
|
# Get all UTXOs up front to ensure none of the transactions spend from each other, as that may
|
||||||
# change their effective feerate and thus the order in which they are selected for eviction.
|
# change their effective feerate and thus the order in which they are selected for eviction.
|
||||||
confirmed_utxos = [ephemeral_miniwallet.get_utxo(confirmed_only=True) for _ in range(num_of_batches * tx_batch_size + 1)]
|
confirmed_utxos = [ephemeral_miniwallet.get_utxo(confirmed_only=True) for _ in range(num_of_batches * tx_batch_size + 2)]
|
||||||
assert_equal(len(confirmed_utxos), num_of_batches * tx_batch_size + 1)
|
assert_equal(len(confirmed_utxos), num_of_batches * tx_batch_size + 2)
|
||||||
|
|
||||||
test_framework.log.debug("Create a mempool tx that will be evicted")
|
test_framework.log.debug("Create a mempool tx that will be evicted")
|
||||||
tx_to_be_evicted_id = ephemeral_miniwallet.send_self_transfer(
|
tx_to_be_evicted_id = ephemeral_miniwallet.send_self_transfer(
|
||||||
|
@ -70,6 +71,14 @@ def fill_mempool(test_framework, node):
|
||||||
create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
|
create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos)
|
||||||
del confirmed_utxos[:tx_batch_size]
|
del confirmed_utxos[:tx_batch_size]
|
||||||
|
|
||||||
|
# if mempool is almost full (<10k usage bytes left), submit one extra middle-sized tx,
|
||||||
|
# in order to evict a large filler tx and leave some room; this will enable tests to submit
|
||||||
|
# txs with just the mempoolminfee without immediate eviction ("mempool full" error)
|
||||||
|
if node.getmempoolinfo()['usage'] >= 4_990_000:
|
||||||
|
ephemeral_miniwallet.send_self_transfer(from_node=node, fee=num_of_batches * (base_fee / 2),
|
||||||
|
utxo_to_spend=confirmed_utxos.pop(0), target_weight = 32500 * 4)
|
||||||
|
assert_greater_than(4_990_000, node.getmempoolinfo()['usage'])
|
||||||
|
|
||||||
test_framework.log.debug("The tx should be evicted by now")
|
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
|
# The number of transactions created should be greater than the ones present in the mempool
|
||||||
assert_greater_than(tx_batch_size * num_of_batches, len(node.getrawmempool()))
|
assert_greater_than(tx_batch_size * num_of_batches, len(node.getrawmempool()))
|
||||||
|
|
Loading…
Add table
Reference in a new issue