From b4a5ab96b42957a0e2110525b9e2e450deda09c1 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Tue, 9 Aug 2022 15:04:59 +0200 Subject: test: refactor: deduplicate `DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT` constants --- test/functional/mempool_package_onemore.py | 7 +++---- test/functional/mempool_packages.py | 11 +++++++---- test/functional/test_framework/messages.py | 3 +++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/functional/mempool_package_onemore.py b/test/functional/mempool_package_onemore.py index 11e3adb700..9a981bd5a5 100755 --- a/test/functional/mempool_package_onemore.py +++ b/test/functional/mempool_package_onemore.py @@ -7,6 +7,9 @@ size. """ +from test_framework.messages import ( + DEFAULT_ANCESTOR_LIMIT, +) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -15,10 +18,6 @@ from test_framework.util import ( from test_framework.wallet import MiniWallet -DEFAULT_ANCESTOR_LIMIT = 25 -DEFAULT_DESCENDANT_LIMIT = 25 - - class MempoolPackagesTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index 99bf148827..def0b1fce4 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -7,7 +7,11 @@ from decimal import Decimal from test_framework.blocktools import COINBASE_MATURITY -from test_framework.messages import COIN +from test_framework.messages import ( + COIN, + DEFAULT_ANCESTOR_LIMIT, + DEFAULT_DESCENDANT_LIMIT, +) from test_framework.p2p import P2PTxInvStore from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( @@ -16,14 +20,13 @@ from test_framework.util import ( chain_transaction, ) -# default limits -DEFAULT_ANCESTOR_LIMIT = 25 -DEFAULT_DESCENDANT_LIMIT = 25 + # custom limits for node1 CUSTOM_ANCESTOR_LIMIT = 5 CUSTOM_DESCENDANT_LIMIT = 10 assert CUSTOM_DESCENDANT_LIMIT >= CUSTOM_ANCESTOR_LIMIT + class MempoolPackagesTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 4a68312379..b323c52e5e 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -65,6 +65,9 @@ FILTER_TYPE_BASIC = 0 WITNESS_SCALE_FACTOR = 4 +DEFAULT_ANCESTOR_LIMIT = 25 # default max number of in-mempool ancestors +DEFAULT_DESCENDANT_LIMIT = 25 # default max number of in-mempool descendants + def sha256(s): return hashlib.sha256(s).digest() -- cgit v1.2.3