diff options
author | glozow <gloriajzhao@gmail.com> | 2023-04-17 12:25:04 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2023-04-17 12:35:23 +0100 |
commit | bf77fc9cb45209b9c560208c65abc94209cd7919 (patch) | |
tree | fed21d42608e7149542cc94ff2b5e25eca717bdc /test/functional/mempool_limit.py | |
parent | b51ebccc28e66c1822ab22d2d178be55c6618196 (diff) |
[test] mempool full in package accept
Diffstat (limited to 'test/functional/mempool_limit.py')
-rwxr-xr-x | test/functional/mempool_limit.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/test/functional/mempool_limit.py b/test/functional/mempool_limit.py index f8e86cafab..f3f4b42ad0 100755 --- a/test/functional/mempool_limit.py +++ b/test/functional/mempool_limit.py @@ -44,8 +44,8 @@ class MempoolLimitTest(BitcoinTestFramework): assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000')) assert_equal(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000')) - tx_batch_size = 25 - num_of_batches = 3 + tx_batch_size = 1 + num_of_batches = 75 # Generate UTXOs to flood the mempool # 1 to create a tx initially that will be evicted from the mempool later # 3 batches of multiple transactions with a fee rate much higher than the previous UTXO @@ -119,7 +119,31 @@ class MempoolLimitTest(BitcoinTestFramework): # The node will broadcast each transaction, still abiding by its peer's fee filter peer.wait_for_broadcast([tx["tx"].getwtxid() for tx in package_txns]) - self.generate(node, 1) + + self.log.info("Check a package that passes mempoolminfee but is evicted immediately after submission") + mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"] + current_mempool = node.getrawmempool(verbose=False) + worst_feerate_btcvb = Decimal("21000000") + for txid in current_mempool: + entry = node.getmempoolentry(txid) + worst_feerate_btcvb = min(worst_feerate_btcvb, entry["fees"]["descendant"] / entry["descendantsize"]) + # Needs to be large enough to trigger eviction + target_weight_each = 200000 + assert_greater_than(target_weight_each * 2, node.getmempoolinfo()["maxmempool"] - node.getmempoolinfo()["bytes"]) + # Should be a true CPFP: parent's feerate is just below mempool min feerate + parent_fee = (mempoolmin_feerate / 1000) * (target_weight_each // 4) - Decimal("0.00001") + # Parent + child is above mempool minimum feerate + child_fee = (worst_feerate_btcvb) * (target_weight_each // 4) - Decimal("0.00001") + # However, when eviction is triggered, these transactions should be at the bottom. + # This assertion assumes parent and child are the same size. + miniwallet.rescan_utxos() + tx_parent_just_below = miniwallet.create_self_transfer(fee=parent_fee, target_weight=target_weight_each) + tx_child_just_above = miniwallet.create_self_transfer(utxo_to_spend=tx_parent_just_below["new_utxo"], fee=child_fee, target_weight=target_weight_each) + # This package ranks below the lowest descendant package in the mempool + assert_greater_than(worst_feerate_btcvb, (parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize())) + assert_greater_than(mempoolmin_feerate, (parent_fee) / (tx_parent_just_below["tx"].get_vsize())) + assert_greater_than((parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()), mempoolmin_feerate / 1000) + assert_raises_rpc_error(-26, "mempool full", node.submitpackage, [tx_parent_just_below["hex"], tx_child_just_above["hex"]]) self.log.info('Test passing a value below the minimum (5 MB) to -maxmempool throws an error') self.stop_node(0) |