17
17
)
18
18
19
19
# default limits
20
- MAX_ANCESTORS = 25
21
- MAX_DESCENDANTS = 25
20
+ DEFAULT_ANCESTOR_LIMIT = 25
21
+ DEFAULT_DESCENDANT_LIMIT = 25
22
22
# custom limits for node1
23
- MAX_ANCESTORS_CUSTOM = 5
24
- MAX_DESCENDANTS_CUSTOM = 10
25
- assert MAX_DESCENDANTS_CUSTOM >= MAX_ANCESTORS_CUSTOM
23
+ CUSTOM_ANCESTOR_LIMIT = 5
24
+ CUSTOM_DESCENDANT_LIMIT = 10
25
+ assert CUSTOM_DESCENDANT_LIMIT >= CUSTOM_ANCESTOR_LIMIT
26
26
27
27
class MempoolPackagesTest (BitcoinTestFramework ):
28
28
def set_test_params (self ):
@@ -34,8 +34,8 @@ def set_test_params(self):
34
34
],
35
35
[
36
36
"-maxorphantx=1000" ,
37
- "-limitancestorcount={}" .format (MAX_ANCESTORS_CUSTOM ),
38
- "-limitdescendantcount={}" .format (MAX_DESCENDANTS_CUSTOM ),
37
+ "-limitancestorcount={}" .format (CUSTOM_ANCESTOR_LIMIT ),
38
+ "-limitdescendantcount={}" .format (CUSTOM_DESCENDANT_LIMIT ),
39
39
],
40
40
]
41
41
@@ -55,12 +55,12 @@ def run_test(self):
55
55
assert 'ancestorfees' not in utxo [0 ]
56
56
57
57
fee = Decimal ("0.0001" )
58
- # MAX_ANCESTORS transactions off a confirmed tx should be fine
58
+ # DEFAULT_ANCESTOR_LIMIT transactions off a confirmed tx should be fine
59
59
chain = []
60
60
witness_chain = []
61
61
ancestor_vsize = 0
62
62
ancestor_fees = Decimal (0 )
63
- for i in range (MAX_ANCESTORS ):
63
+ for i in range (DEFAULT_ANCESTOR_LIMIT ):
64
64
(txid , sent_value ) = chain_transaction (self .nodes [0 ], [txid ], [0 ], value , fee , 1 )
65
65
value = sent_value
66
66
chain .append (txid )
@@ -81,16 +81,16 @@ def run_test(self):
81
81
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between
82
82
peer_inv_store .wait_for_broadcast (witness_chain )
83
83
84
- # Check mempool has MAX_ANCESTORS transactions in it, and descendant and ancestor
84
+ # Check mempool has DEFAULT_ANCESTOR_LIMIT transactions in it, and descendant and ancestor
85
85
# count and fees should look correct
86
86
mempool = self .nodes [0 ].getrawmempool (True )
87
- assert_equal (len (mempool ), MAX_ANCESTORS )
87
+ assert_equal (len (mempool ), DEFAULT_ANCESTOR_LIMIT )
88
88
descendant_count = 1
89
89
descendant_fees = 0
90
90
descendant_vsize = 0
91
91
92
92
assert_equal (ancestor_vsize , sum ([mempool [tx ]['vsize' ] for tx in mempool ]))
93
- ancestor_count = MAX_ANCESTORS
93
+ ancestor_count = DEFAULT_ANCESTOR_LIMIT
94
94
assert_equal (ancestor_fees , sum ([mempool [tx ]['fees' ]['base' ] for tx in mempool ]))
95
95
96
96
descendants = []
@@ -213,9 +213,9 @@ def run_test(self):
213
213
# Check that node1's mempool is as expected (-> custom ancestor limit)
214
214
mempool0 = self .nodes [0 ].getrawmempool (False )
215
215
mempool1 = self .nodes [1 ].getrawmempool (False )
216
- assert_equal (len (mempool1 ), MAX_ANCESTORS_CUSTOM )
216
+ assert_equal (len (mempool1 ), CUSTOM_ANCESTOR_LIMIT )
217
217
assert set (mempool1 ).issubset (set (mempool0 ))
218
- for tx in chain [:MAX_ANCESTORS_CUSTOM ]:
218
+ for tx in chain [:CUSTOM_ANCESTOR_LIMIT ]:
219
219
assert tx in mempool1
220
220
# TODO: more detailed check of node1's mempool (fees etc.)
221
221
# check transaction unbroadcast info (should be false if in both mempools)
@@ -240,7 +240,7 @@ def run_test(self):
240
240
241
241
# Sign and send up to MAX_DESCENDANT transactions chained off the parent tx
242
242
chain = [] # save sent txs for the purpose of checking node1's mempool later (see below)
243
- for _ in range (MAX_DESCENDANTS - 1 ):
243
+ for _ in range (DEFAULT_DESCENDANT_LIMIT - 1 ):
244
244
utxo = transaction_package .pop (0 )
245
245
(txid , sent_value ) = chain_transaction (self .nodes [0 ], [utxo ['txid' ]], [utxo ['vout' ]], utxo ['amount' ], fee , 10 )
246
246
chain .append (txid )
@@ -250,7 +250,7 @@ def run_test(self):
250
250
transaction_package .append ({'txid' : txid , 'vout' : j , 'amount' : sent_value })
251
251
252
252
mempool = self .nodes [0 ].getrawmempool (True )
253
- assert_equal (mempool [parent_transaction ]['descendantcount' ], MAX_DESCENDANTS )
253
+ assert_equal (mempool [parent_transaction ]['descendantcount' ], DEFAULT_DESCENDANT_LIMIT )
254
254
assert_equal (sorted (mempool [parent_transaction ]['spentby' ]), sorted (tx_children ))
255
255
256
256
for child in tx_children :
@@ -265,14 +265,14 @@ def run_test(self):
265
265
# - parent tx for descendant test
266
266
# - txs chained off parent tx (-> custom descendant limit)
267
267
self .wait_until (lambda : len (self .nodes [1 ].getrawmempool ()) ==
268
- MAX_ANCESTORS_CUSTOM + 1 + MAX_DESCENDANTS_CUSTOM , timeout = 10 )
268
+ CUSTOM_ANCESTOR_LIMIT + 1 + CUSTOM_DESCENDANT_LIMIT , timeout = 10 )
269
269
mempool0 = self .nodes [0 ].getrawmempool (False )
270
270
mempool1 = self .nodes [1 ].getrawmempool (False )
271
271
assert set (mempool1 ).issubset (set (mempool0 ))
272
272
assert parent_transaction in mempool1
273
- for tx in chain [:MAX_DESCENDANTS_CUSTOM ]:
273
+ for tx in chain [:CUSTOM_DESCENDANT_LIMIT ]:
274
274
assert tx in mempool1
275
- for tx in chain [MAX_DESCENDANTS_CUSTOM :]:
275
+ for tx in chain [CUSTOM_DESCENDANT_LIMIT :]:
276
276
assert tx not in mempool1
277
277
# TODO: more detailed check of node1's mempool (fees etc.)
278
278
0 commit comments