3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Helpful routines for mempool testing."""
6
- from decimal import Decimal
7
6
import random
8
7
9
8
from .blocktools import (
@@ -62,9 +61,7 @@ def fill_mempool(test_framework, node, *, tx_sync_fun=None):
62
61
"""
63
62
test_framework .log .info ("Fill the mempool until eviction is triggered and the mempoolminfee rises" )
64
63
txouts = gen_return_txouts ()
65
- relayfee = node .getnetworkinfo ()['relayfee' ]
66
-
67
- assert_equal (relayfee , Decimal ('0.00001000' ))
64
+ minrelayfee = node .getnetworkinfo ()['relayfee' ]
68
65
69
66
tx_batch_size = 1
70
67
num_of_batches = 75
@@ -84,7 +81,7 @@ def fill_mempool(test_framework, node, *, tx_sync_fun=None):
84
81
85
82
test_framework .log .debug ("Create a mempool tx that will be evicted" )
86
83
tx_to_be_evicted_id = ephemeral_miniwallet .send_self_transfer (
87
- from_node = node , utxo_to_spend = confirmed_utxos .pop (0 ), fee_rate = relayfee )["txid" ]
84
+ from_node = node , utxo_to_spend = confirmed_utxos .pop (0 ), fee_rate = minrelayfee )["txid" ]
88
85
89
86
def send_batch (fee ):
90
87
utxos = confirmed_utxos [:tx_batch_size ]
@@ -94,14 +91,14 @@ def send_batch(fee):
94
91
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
95
92
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
96
93
# by 130 should result in a fee that corresponds to 2x of that fee rate
97
- base_fee = relayfee * 130
94
+ base_fee = minrelayfee * 130
98
95
batch_fees = [(i + 1 ) * base_fee for i in range (num_of_batches )]
99
96
100
97
test_framework .log .debug ("Fill up the mempool with txs with higher fee rate" )
101
98
for fee in batch_fees [:- 3 ]:
102
99
send_batch (fee )
103
100
tx_sync_fun () if tx_sync_fun else test_framework .sync_mempools () # sync before any eviction
104
- assert_equal (node .getmempoolinfo ()["mempoolminfee" ], Decimal ( "0.00001000" ) )
101
+ assert_equal (node .getmempoolinfo ()["mempoolminfee" ], minrelayfee )
105
102
for fee in batch_fees [- 3 :]:
106
103
send_batch (fee )
107
104
tx_sync_fun () if tx_sync_fun else test_framework .sync_mempools () # sync after all evictions
@@ -113,8 +110,8 @@ def send_batch(fee):
113
110
assert tx_to_be_evicted_id not in node .getrawmempool ()
114
111
115
112
test_framework .log .debug ("Check that mempoolminfee is larger than minrelaytxfee" )
116
- assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], Decimal ( '0.00001000' ) )
117
- assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], Decimal ( '0.00001000' ) )
113
+ assert_equal (node .getmempoolinfo ()['minrelaytxfee' ], minrelayfee )
114
+ assert_greater_than (node .getmempoolinfo ()['mempoolminfee' ], minrelayfee )
118
115
119
116
def tx_in_orphanage (node , tx : CTransaction ) -> bool :
120
117
"""Returns true if the transaction is in the orphanage."""
0 commit comments