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
"""Test logic for limiting mempool and package ancestors/descendants."""
6
-
7
- from decimal import Decimal
8
-
9
6
from test_framework .blocktools import COINBASE_MATURITY
10
- from test_framework .test_framework import BitcoinTestFramework
11
7
from test_framework .messages import (
12
- COIN ,
13
8
WITNESS_SCALE_FACTOR ,
14
9
)
10
+ from test_framework .test_framework import BitcoinTestFramework
15
11
from test_framework .util import (
16
12
assert_equal ,
17
13
)
18
14
from test_framework .wallet import MiniWallet
19
15
16
+
20
17
class MempoolPackageLimitsTest (BitcoinTestFramework ):
21
18
def set_test_params (self ):
22
19
self .num_nodes = 1
@@ -304,8 +301,9 @@ def test_anc_size_limits(self):
304
301
node = self .nodes [0 ]
305
302
assert_equal (0 , node .getmempoolinfo ()["size" ])
306
303
parent_utxos = []
307
- target_weight = WITNESS_SCALE_FACTOR * 1000 * 30 # 30KvB
308
- high_fee = Decimal ("0.003" ) # 10 sats/vB
304
+ target_vsize = 30_000
305
+ high_fee = 10 * target_vsize # 10 sats/vB
306
+ target_weight = target_vsize * WITNESS_SCALE_FACTOR
309
307
self .log .info ("Check that in-mempool and in-package ancestor size limits are calculated properly in packages" )
310
308
# Mempool transactions A and B
311
309
for _ in range (2 ):
@@ -314,7 +312,7 @@ def test_anc_size_limits(self):
314
312
parent_utxos .append (bulked_tx ["new_utxo" ])
315
313
316
314
# Package transaction C
317
- pc_tx = self .wallet .create_self_transfer_multi (utxos_to_spend = parent_utxos , fee_per_output = int ( high_fee * COIN ) , target_weight = target_weight )
315
+ pc_tx = self .wallet .create_self_transfer_multi (utxos_to_spend = parent_utxos , fee_per_output = high_fee , target_weight = target_weight )
318
316
319
317
# Package transaction D
320
318
pd_tx = self .wallet .create_self_transfer (utxo_to_spend = pc_tx ["new_utxos" ][0 ], target_weight = target_weight )
@@ -329,7 +327,7 @@ def test_anc_size_limits(self):
329
327
assert all ([res ["allowed" ] for res in node .testmempoolaccept (rawtxs = [pc_tx ["hex" ], pd_tx ["hex" ]])])
330
328
331
329
def test_desc_size_limits (self ):
332
- """Create 3 mempool transactions and 2 package transactions (25KvB each):
330
+ """Create 3 mempool transactions and 2 package transactions (21KvB each):
333
331
Ma
334
332
^ ^
335
333
Mb Mc
@@ -340,11 +338,12 @@ def test_desc_size_limits(self):
340
338
"""
341
339
node = self .nodes [0 ]
342
340
assert_equal (0 , node .getmempoolinfo ()["size" ])
343
- target_weight = 21 * 1000 * WITNESS_SCALE_FACTOR
344
- high_fee = Decimal ("0.0021" ) # 10 sats/vB
341
+ target_vsize = 21_000
342
+ high_fee = 10 * target_vsize # 10 sats/vB
343
+ target_weight = target_vsize * WITNESS_SCALE_FACTOR
345
344
self .log .info ("Check that in-mempool and in-package descendant sizes are calculated properly in packages" )
346
345
# Top parent in mempool, Ma
347
- ma_tx = self .wallet .create_self_transfer_multi (num_outputs = 2 , fee_per_output = int ( high_fee / 2 * COIN ) , target_weight = target_weight )
346
+ ma_tx = self .wallet .create_self_transfer_multi (num_outputs = 2 , fee_per_output = high_fee // 2 , target_weight = target_weight )
348
347
self .wallet .sendrawtransaction (from_node = node , tx_hex = ma_tx ["hex" ])
349
348
350
349
package_hex = []
@@ -367,5 +366,6 @@ def test_desc_size_limits(self):
367
366
self .generate (node , 1 )
368
367
assert all ([res ["allowed" ] for res in node .testmempoolaccept (rawtxs = package_hex )])
369
368
369
+
370
370
if __name__ == "__main__" :
371
371
MempoolPackageLimitsTest ().main ()
0 commit comments