Skip to content

Commit b4a5ab9

Browse files
committed
test: refactor: deduplicate DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT constants
1 parent 0fda1c7 commit b4a5ab9

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

test/functional/mempool_package_onemore.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
size.
88
"""
99

10+
from test_framework.messages import (
11+
DEFAULT_ANCESTOR_LIMIT,
12+
)
1013
from test_framework.test_framework import BitcoinTestFramework
1114
from test_framework.util import (
1215
assert_equal,
@@ -15,10 +18,6 @@
1518
from test_framework.wallet import MiniWallet
1619

1720

18-
DEFAULT_ANCESTOR_LIMIT = 25
19-
DEFAULT_DESCENDANT_LIMIT = 25
20-
21-
2221
class MempoolPackagesTest(BitcoinTestFramework):
2322
def set_test_params(self):
2423
self.num_nodes = 1

test/functional/mempool_packages.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from decimal import Decimal
88

99
from test_framework.blocktools import COINBASE_MATURITY
10-
from test_framework.messages import COIN
10+
from test_framework.messages import (
11+
COIN,
12+
DEFAULT_ANCESTOR_LIMIT,
13+
DEFAULT_DESCENDANT_LIMIT,
14+
)
1115
from test_framework.p2p import P2PTxInvStore
1216
from test_framework.test_framework import BitcoinTestFramework
1317
from test_framework.util import (
@@ -16,14 +20,13 @@
1620
chain_transaction,
1721
)
1822

19-
# default limits
20-
DEFAULT_ANCESTOR_LIMIT = 25
21-
DEFAULT_DESCENDANT_LIMIT = 25
23+
2224
# custom limits for node1
2325
CUSTOM_ANCESTOR_LIMIT = 5
2426
CUSTOM_DESCENDANT_LIMIT = 10
2527
assert CUSTOM_DESCENDANT_LIMIT >= CUSTOM_ANCESTOR_LIMIT
2628

29+
2730
class MempoolPackagesTest(BitcoinTestFramework):
2831
def set_test_params(self):
2932
self.num_nodes = 2

test/functional/test_framework/messages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565

6666
WITNESS_SCALE_FACTOR = 4
6767

68+
DEFAULT_ANCESTOR_LIMIT = 25 # default max number of in-mempool ancestors
69+
DEFAULT_DESCENDANT_LIMIT = 25 # default max number of in-mempool descendants
70+
6871

6972
def sha256(s):
7073
return hashlib.sha256(s).digest()

0 commit comments

Comments
 (0)