|
19 | 19 | )
|
20 | 20 |
|
21 | 21 |
|
22 |
| -def fill_mempool(test_framework, node): |
| 22 | +def fill_mempool(test_framework, node, *, tx_sync_fun=None): |
23 | 23 | """Fill mempool until eviction.
|
24 | 24 |
|
25 | 25 | Allows for simpler testing of scenarios with floating mempoolminfee > minrelay
|
26 |
| - Requires -datacarriersize=100000 and |
27 |
| - -maxmempool=5. |
28 |
| - It will not ensure mempools become synced as it |
29 |
| - is based on a single node and assumes -minrelaytxfee |
| 26 | + Requires -datacarriersize=100000 and -maxmempool=5 and assumes -minrelaytxfee |
30 | 27 | is 1 sat/vbyte.
|
31 | 28 | To avoid unintentional tx dependencies, the mempool filling txs are created with a
|
32 | 29 | tagged ephemeral miniwallet instance.
|
@@ -57,18 +54,25 @@ def fill_mempool(test_framework, node):
|
57 | 54 | tx_to_be_evicted_id = ephemeral_miniwallet.send_self_transfer(
|
58 | 55 | from_node=node, utxo_to_spend=confirmed_utxos.pop(0), fee_rate=relayfee)["txid"]
|
59 | 56 |
|
| 57 | + def send_batch(fee): |
| 58 | + utxos = confirmed_utxos[:tx_batch_size] |
| 59 | + create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos) |
| 60 | + del confirmed_utxos[:tx_batch_size] |
| 61 | + |
60 | 62 | # Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
|
61 | 63 | # The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
|
62 | 64 | # by 130 should result in a fee that corresponds to 2x of that fee rate
|
63 | 65 | base_fee = relayfee * 130
|
| 66 | + batch_fees = [(i + 1) * base_fee for i in range(num_of_batches)] |
64 | 67 |
|
65 | 68 | test_framework.log.debug("Fill up the mempool with txs with higher fee rate")
|
66 |
| - with node.assert_debug_log(["rolling minimum fee bumped"]): |
67 |
| - for batch_of_txid in range(num_of_batches): |
68 |
| - fee = (batch_of_txid + 1) * base_fee |
69 |
| - utxos = confirmed_utxos[:tx_batch_size] |
70 |
| - create_lots_of_big_transactions(ephemeral_miniwallet, node, fee, tx_batch_size, txouts, utxos) |
71 |
| - del confirmed_utxos[:tx_batch_size] |
| 69 | + for fee in batch_fees[:-3]: |
| 70 | + send_batch(fee) |
| 71 | + tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync before any eviction |
| 72 | + assert_equal(node.getmempoolinfo()["mempoolminfee"], Decimal("0.00001000")) |
| 73 | + for fee in batch_fees[-3:]: |
| 74 | + send_batch(fee) |
| 75 | + tx_sync_fun() if tx_sync_fun else test_framework.sync_mempools() # sync after all evictions |
72 | 76 |
|
73 | 77 | test_framework.log.debug("The tx should be evicted by now")
|
74 | 78 | # The number of transactions created should be greater than the ones present in the mempool
|
|
0 commit comments