Skip to content

Commit 0fda1c7

Browse files
committed
scripted-diff: test: rename MAX_{ANCESTORS,DESCENDANTS} to DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT
-BEGIN VERIFY SCRIPT- ren() { sed -i "s:$1:$2:g" $(git grep -l "$1" ./test); } ren MAX_ANCESTORS_CUSTOM CUSTOM_ANCESTOR_LIMIT ren MAX_DESCENDANTS_CUSTOM CUSTOM_DESCENDANT_LIMIT ren MAX_ANCESTORS DEFAULT_ANCESTOR_LIMIT ren MAX_DESCENDANTS DEFAULT_DESCENDANT_LIMIT -END VERIFY SCRIPT-
1 parent c012875 commit 0fda1c7

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

test/functional/mempool_package_onemore.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from test_framework.wallet import MiniWallet
1616

1717

18-
MAX_ANCESTORS = 25
19-
MAX_DESCENDANTS = 25
18+
DEFAULT_ANCESTOR_LIMIT = 25
19+
DEFAULT_DESCENDANT_LIMIT = 25
2020

2121

2222
class MempoolPackagesTest(BitcoinTestFramework):
@@ -34,19 +34,19 @@ def run_test(self):
3434
self.wallet = MiniWallet(self.nodes[0])
3535
self.wallet.rescan_utxos()
3636

37-
# MAX_ANCESTORS transactions off a confirmed tx should be fine
37+
# DEFAULT_ANCESTOR_LIMIT transactions off a confirmed tx should be fine
3838
chain = []
3939
utxo = self.wallet.get_utxo()
4040
for _ in range(4):
4141
utxo, utxo2 = self.chain_tx([utxo], num_outputs=2)
4242
chain.append(utxo2)
43-
for _ in range(MAX_ANCESTORS - 4):
43+
for _ in range(DEFAULT_ANCESTOR_LIMIT - 4):
4444
utxo, = self.chain_tx([utxo])
4545
chain.append(utxo)
4646
second_chain, = self.chain_tx([self.wallet.get_utxo()])
4747

48-
# Check mempool has MAX_ANCESTORS + 1 transactions in it
49-
assert_equal(len(self.nodes[0].getrawmempool()), MAX_ANCESTORS + 1)
48+
# Check mempool has DEFAULT_ANCESTOR_LIMIT + 1 transactions in it
49+
assert_equal(len(self.nodes[0].getrawmempool()), DEFAULT_ANCESTOR_LIMIT + 1)
5050

5151
# Adding one more transaction on to the chain should fail.
5252
assert_raises_rpc_error(-26, "too-long-mempool-chain, too many unconfirmed ancestors [limit: 25]", self.chain_tx, [utxo])
@@ -67,7 +67,7 @@ def run_test(self):
6767
self.nodes[0].sendrawtransaction(replacable_tx.serialize().hex())
6868

6969
# Finally, check that we added two transactions
70-
assert_equal(len(self.nodes[0].getrawmempool()), MAX_ANCESTORS + 3)
70+
assert_equal(len(self.nodes[0].getrawmempool()), DEFAULT_ANCESTOR_LIMIT + 3)
7171

7272

7373
if __name__ == '__main__':

test/functional/mempool_packages.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
)
1818

1919
# default limits
20-
MAX_ANCESTORS = 25
21-
MAX_DESCENDANTS = 25
20+
DEFAULT_ANCESTOR_LIMIT = 25
21+
DEFAULT_DESCENDANT_LIMIT = 25
2222
# 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
2626

2727
class MempoolPackagesTest(BitcoinTestFramework):
2828
def set_test_params(self):
@@ -34,8 +34,8 @@ def set_test_params(self):
3434
],
3535
[
3636
"-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),
3939
],
4040
]
4141

@@ -55,12 +55,12 @@ def run_test(self):
5555
assert 'ancestorfees' not in utxo[0]
5656

5757
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
5959
chain = []
6060
witness_chain = []
6161
ancestor_vsize = 0
6262
ancestor_fees = Decimal(0)
63-
for i in range(MAX_ANCESTORS):
63+
for i in range(DEFAULT_ANCESTOR_LIMIT):
6464
(txid, sent_value) = chain_transaction(self.nodes[0], [txid], [0], value, fee, 1)
6565
value = sent_value
6666
chain.append(txid)
@@ -81,16 +81,16 @@ def run_test(self):
8181
# Otherwise, getrawmempool may be inconsistent with getmempoolentry if unbroadcast changes in between
8282
peer_inv_store.wait_for_broadcast(witness_chain)
8383

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
8585
# count and fees should look correct
8686
mempool = self.nodes[0].getrawmempool(True)
87-
assert_equal(len(mempool), MAX_ANCESTORS)
87+
assert_equal(len(mempool), DEFAULT_ANCESTOR_LIMIT)
8888
descendant_count = 1
8989
descendant_fees = 0
9090
descendant_vsize = 0
9191

9292
assert_equal(ancestor_vsize, sum([mempool[tx]['vsize'] for tx in mempool]))
93-
ancestor_count = MAX_ANCESTORS
93+
ancestor_count = DEFAULT_ANCESTOR_LIMIT
9494
assert_equal(ancestor_fees, sum([mempool[tx]['fees']['base'] for tx in mempool]))
9595

9696
descendants = []
@@ -213,9 +213,9 @@ def run_test(self):
213213
# Check that node1's mempool is as expected (-> custom ancestor limit)
214214
mempool0 = self.nodes[0].getrawmempool(False)
215215
mempool1 = self.nodes[1].getrawmempool(False)
216-
assert_equal(len(mempool1), MAX_ANCESTORS_CUSTOM)
216+
assert_equal(len(mempool1), CUSTOM_ANCESTOR_LIMIT)
217217
assert set(mempool1).issubset(set(mempool0))
218-
for tx in chain[:MAX_ANCESTORS_CUSTOM]:
218+
for tx in chain[:CUSTOM_ANCESTOR_LIMIT]:
219219
assert tx in mempool1
220220
# TODO: more detailed check of node1's mempool (fees etc.)
221221
# check transaction unbroadcast info (should be false if in both mempools)
@@ -240,7 +240,7 @@ def run_test(self):
240240

241241
# Sign and send up to MAX_DESCENDANT transactions chained off the parent tx
242242
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):
244244
utxo = transaction_package.pop(0)
245245
(txid, sent_value) = chain_transaction(self.nodes[0], [utxo['txid']], [utxo['vout']], utxo['amount'], fee, 10)
246246
chain.append(txid)
@@ -250,7 +250,7 @@ def run_test(self):
250250
transaction_package.append({'txid': txid, 'vout': j, 'amount': sent_value})
251251

252252
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)
254254
assert_equal(sorted(mempool[parent_transaction]['spentby']), sorted(tx_children))
255255

256256
for child in tx_children:
@@ -265,14 +265,14 @@ def run_test(self):
265265
# - parent tx for descendant test
266266
# - txs chained off parent tx (-> custom descendant limit)
267267
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)
269269
mempool0 = self.nodes[0].getrawmempool(False)
270270
mempool1 = self.nodes[1].getrawmempool(False)
271271
assert set(mempool1).issubset(set(mempool0))
272272
assert parent_transaction in mempool1
273-
for tx in chain[:MAX_DESCENDANTS_CUSTOM]:
273+
for tx in chain[:CUSTOM_DESCENDANT_LIMIT]:
274274
assert tx in mempool1
275-
for tx in chain[MAX_DESCENDANTS_CUSTOM:]:
275+
for tx in chain[CUSTOM_DESCENDANT_LIMIT:]:
276276
assert tx not in mempool1
277277
# TODO: more detailed check of node1's mempool (fees etc.)
278278

0 commit comments

Comments
 (0)