Skip to content

Commit c985eb8

Browse files
committed
test: add option to speed up tx relay/mempool sync
when `self.noban_tx_relay=True`, the following flag `-whitelist=noban,in,[email protected]`is added to `extra_args` to speed up tx relay/mempool sync.
1 parent 66bc6e2 commit c985eb8

31 files changed

+76
-64
lines changed

Diff for: test/functional/feature_cltv.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ def cltv_validate(tx, height):
8383
class BIP65Test(BitcoinTestFramework):
8484
def set_test_params(self):
8585
self.num_nodes = 1
86+
# whitelist peers to speed up tx relay / mempool sync
87+
self.noban_tx_relay = True
8688
self.extra_args = [[
8789
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
88-
8990
'-par=1', # Use only one script thread to get the exact reject reason for testing
9091
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
9192
]]

Diff for: test/functional/feature_csv_activation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ class BIP68_112_113Test(BitcoinTestFramework):
9595
def set_test_params(self):
9696
self.num_nodes = 1
9797
self.setup_clean_chain = True
98+
# whitelist peers to speed up tx relay / mempool sync
99+
self.noban_tx_relay = True
98100
self.extra_args = [[
99-
100101
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
101102
'-par=1', # Use only one script thread to get the exact reject reason for testing
102103
]]

Diff for: test/functional/feature_dersig.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ def unDERify(tx):
4747
class BIP66Test(BitcoinTestFramework):
4848
def set_test_params(self):
4949
self.num_nodes = 1
50+
# whitelist peers to speed up tx relay / mempool sync
51+
self.noban_tx_relay = True
5052
self.extra_args = [[
5153
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
52-
5354
'-par=1', # Use only one script thread to get the exact log msg for testing
5455
]]
5556
self.setup_clean_chain = True

Diff for: test/functional/feature_fee_estimation.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ def make_tx(wallet, utxo, feerate):
132132
class EstimateFeeTest(BitcoinTestFramework):
133133
def set_test_params(self):
134134
self.num_nodes = 3
135-
# Force fSendTrickle to true (via whitelist.noban)
135+
# whitelist peers to speed up tx relay / mempool sync
136+
self.noban_tx_relay = True
136137
self.extra_args = [
137-
138-
["-[email protected]", "-blockmaxweight=68000"],
139-
["-[email protected]", "-blockmaxweight=32000"],
138+
[],
139+
["-blockmaxweight=68000"],
140+
["-blockmaxweight=32000"],
140141
]
141142

142143
def setup_network(self):

Diff for: test/functional/interface_rest.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def set_test_params(self):
5353
self.num_nodes = 2
5454
self.extra_args = [["-rest", "-blockfilterindex=1"], []]
5555
# whitelist peers to speed up tx relay / mempool sync
56-
for args in self.extra_args:
57-
args.append("[email protected]")
56+
self.noban_tx_relay = True
5857
self.supports_cli = False
5958

6059
def test_rest_request(

Diff for: test/functional/interface_zmq.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ def caused_notification(self, notification):
104104
class ZMQTest (BitcoinTestFramework):
105105
def set_test_params(self):
106106
self.num_nodes = 2
107-
# This test isn't testing txn relay/timing, so set whitelist on the
108-
# peers for instant txn relay. This speeds up the test run time 2-3x.
109-
self.extra_args = [["[email protected]"]] * self.num_nodes
107+
# whitelist peers to speed up tx relay / mempool sync
108+
self.noban_tx_relay = True
110109
self.zmq_port_base = p2p_port(self.num_nodes + 1)
111110

112111
def skip_test_if_missing_module(self):
@@ -138,8 +137,7 @@ def setup_zmq_test(self, services, *, recv_timeout=60, sync_blocks=True, ipv6=Fa
138137
socket.setsockopt(zmq.IPV6, 1)
139138
subscribers.append(ZMQSubscriber(socket, topic.encode()))
140139

141-
self.restart_node(0, [f"-zmqpub{topic}={address}" for topic, address in services] +
142-
self.extra_args[0])
140+
self.restart_node(0, [f"-zmqpub{topic}={address}" for topic, address in services])
143141

144142
for i, sub in enumerate(subscribers):
145143
sub.socket.connect(services[i][1])

Diff for: test/functional/mempool_packages.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
class MempoolPackagesTest(BitcoinTestFramework):
2828
def set_test_params(self):
2929
self.num_nodes = 2
30+
# whitelist peers to speed up tx relay / mempool sync
31+
self.noban_tx_relay = True
3032
self.extra_args = [
3133
[
3234
"-maxorphantx=1000",
33-
"[email protected]", # immediate tx relay
3435
],
3536
[
3637
"-maxorphantx=1000",

Diff for: test/functional/p2p_feefilter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ def clear_invs(self):
4646
class FeeFilterTest(BitcoinTestFramework):
4747
def set_test_params(self):
4848
self.num_nodes = 2
49+
# whitelist peers to speed up tx relay / mempool sync
50+
self.noban_tx_relay = True
4951
# We lower the various required feerates for this test
5052
# to catch a corner-case where feefilter used to slightly undercut
5153
# mempool and wallet feerate calculation based on GetFee
5254
# rounding down 3 places, leading to stranded transactions.
5355
# See issue #16499
54-
# grant noban permission to all peers to speed up tx relay / mempool sync
5556
self.extra_args = [[
5657
"-minrelaytxfee=0.00000100",
57-
"-mintxfee=0.00000100",
58-
58+
"-mintxfee=0.00000100"
5959
]] * self.num_nodes
6060

6161
def run_test(self):

Diff for: test/functional/p2p_filter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ def merkleblock_received(self, value):
9494
class FilterTest(BitcoinTestFramework):
9595
def set_test_params(self):
9696
self.num_nodes = 1
97+
# whitelist peers to speed up tx relay / mempool sync
98+
self.noban_tx_relay = True
9799
self.extra_args = [[
98100
'-peerbloomfilters',
99-
'[email protected]', # immediate tx relay
100101
]]
101102

102103
def generatetoscriptpubkey(self, scriptpubkey):

Diff for: test/functional/p2p_invalid_block.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
3232
def set_test_params(self):
3333
self.num_nodes = 1
3434
self.setup_clean_chain = True
35-
self.extra_args = [["[email protected]"]]
35+
# whitelist peers to speed up tx relay / mempool sync
36+
self.noban_tx_relay = True
3637

3738
def run_test(self):
3839
# Add p2p connection to node0

Diff for: test/functional/p2p_segwit.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ class SegWitTest(BitcoinTestFramework):
213213
def set_test_params(self):
214214
self.setup_clean_chain = True
215215
self.num_nodes = 2
216+
# whitelist peers to speed up tx relay / mempool sync
217+
self.noban_tx_relay = True
216218
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
217219
self.extra_args = [
218-
["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-[email protected]", "-par=1"],
220+
["-acceptnonstdtxn=1", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}", "-par=1"],
219221
["-acceptnonstdtxn=0", f"-testactivationheight=segwit@{SEGWIT_HEIGHT}"],
220222
]
221223
self.supports_cli = False

Diff for: test/functional/rpc_packages.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class RPCPackagesTest(BitcoinTestFramework):
2929
def set_test_params(self):
3030
self.num_nodes = 1
3131
self.setup_clean_chain = True
32-
self.extra_args = [["[email protected]"]] # noban speeds up tx relay
32+
# whitelist peers to speed up tx relay / mempool sync
33+
self.noban_tx_relay = True
3334

3435
def assert_testres_equal(self, package_hex, testres_expected):
3536
"""Shuffle package_hex and assert that the testmempoolaccept result matches testres_expected. This should only

Diff for: test/functional/rpc_rawtransaction.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ def set_test_params(self):
7373
["-txindex"],
7474
["-fastprune", "-prune=1"],
7575
]
76-
# whitelist all peers to speed up tx relay / mempool sync
77-
for args in self.extra_args:
78-
args.append("[email protected]")
76+
# whitelist peers to speed up tx relay / mempool sync
77+
self.noban_tx_relay = True
7978
self.supports_cli = False
8079

8180
def setup_network(self):

Diff for: test/functional/test_framework/test_framework.py

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self) -> None:
9696
"""Sets test framework defaults. Do not override this method. Instead, override the set_test_params() method"""
9797
self.chain: str = 'regtest'
9898
self.setup_clean_chain: bool = False
99+
self.noban_tx_relay: bool = False
99100
self.nodes: list[TestNode] = []
100101
self.extra_args = None
101102
self.network_thread = None
@@ -494,6 +495,10 @@ def get_bin_from_version(version, bin_name, bin_default):
494495
extra_confs = [[]] * num_nodes
495496
if extra_args is None:
496497
extra_args = [[]] * num_nodes
498+
# Whitelist peers to speed up tx relay / mempool sync. Don't use it if testing tx relay or timing.
499+
if self.noban_tx_relay:
500+
for i in range(len(extra_args)):
501+
extra_args[i] = extra_args[i] + ["-whitelist=noban,in,[email protected]"]
497502
if versions is None:
498503
versions = [None] * num_nodes
499504
if binary is None:

Diff for: test/functional/wallet_abandonconflict.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def set_test_params(self):
2828
self.num_nodes = 2
2929
self.extra_args = [["-minrelaytxfee=0.00001"], []]
3030
# whitelist peers to speed up tx relay / mempool sync
31-
for args in self.extra_args:
32-
args.append("[email protected]")
31+
self.noban_tx_relay = True
3332

3433
def skip_test_if_missing_module(self):
3534
self.skip_if_no_wallet()

Diff for: test/functional/wallet_address_types.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ def set_test_params(self):
7979
["-changetype=p2sh-segwit"],
8080
[],
8181
]
82-
# whitelist all peers to speed up tx relay / mempool sync
83-
for args in self.extra_args:
84-
args.append("[email protected]")
82+
# whitelist peers to speed up tx relay / mempool sync
83+
self.noban_tx_relay = True
8584
self.supports_cli = False
8685

8786
def skip_test_if_missing_module(self):

Diff for: test/functional/wallet_avoid_mixing_output_types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ def add_options(self, parser):
112112
def set_test_params(self):
113113
self.setup_clean_chain = True
114114
self.num_nodes = 2
115+
# whitelist peers to speed up tx relay / mempool sync
116+
self.noban_tx_relay = True
115117
self.extra_args = [
116118
[
117119
"-addresstype=bech32",
118-
119120
"-txindex",
120121
],
121122
[
122123
"-addresstype=p2sh-segwit",
123-
124124
"-txindex",
125125
],
126126
]

Diff for: test/functional/wallet_avoidreuse.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ def add_options(self, parser):
6969

7070
def set_test_params(self):
7171
self.num_nodes = 2
72-
# This test isn't testing txn relay/timing, so set whitelist on the
73-
# peers for instant txn relay. This speeds up the test run time 2-3x.
74-
self.extra_args = [["[email protected]"]] * self.num_nodes
72+
# whitelist peers to speed up tx relay / mempool sync
73+
self.noban_tx_relay = True
7574

7675
def skip_test_if_missing_module(self):
7776
self.skip_if_no_wallet()

Diff for: test/functional/wallet_backup.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ def add_options(self, parser):
5050
def set_test_params(self):
5151
self.num_nodes = 4
5252
self.setup_clean_chain = True
53-
# nodes 1, 2,3 are spenders, let's give them a keypool=100
54-
# whitelist all peers to speed up tx relay / mempool sync
53+
# whitelist peers to speed up tx relay / mempool sync
54+
self.noban_tx_relay = True
55+
# nodes 1, 2, 3 are spenders, let's give them a keypool=100
5556
self.extra_args = [
56-
["-[email protected]", "-keypool=100"],
57-
["-[email protected]", "-keypool=100"],
58-
["-[email protected]", "-keypool=100"],
59-
57+
["-keypool=100"],
58+
["-keypool=100"],
59+
["-keypool=100"],
60+
[],
6061
]
6162
self.rpc_timeout = 120
6263

Diff for: test/functional/wallet_balance.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ def add_options(self, parser):
5353
def set_test_params(self):
5454
self.num_nodes = 2
5555
self.setup_clean_chain = True
56+
# whitelist peers to speed up tx relay / mempool sync
57+
self.noban_tx_relay = True
5658
self.extra_args = [
5759
# Limit mempool descendants as a hack to have wallet txs rejected from the mempool.
5860
# Set walletrejectlongchains=0 so the wallet still creates the transactions.
5961
['-limitdescendantcount=3', '-walletrejectlongchains=0'],
6062
[],
6163
]
62-
# whitelist peers to speed up tx relay / mempool sync
63-
for args in self.extra_args:
64-
args.append("[email protected]")
6564

6665
def skip_test_if_missing_module(self):
6766
self.skip_if_no_wallet()

Diff for: test/functional/wallet_basic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def add_options(self, parser):
3232

3333
def set_test_params(self):
3434
self.num_nodes = 4
35+
# whitelist peers to speed up tx relay / mempool sync
36+
self.noban_tx_relay = True
3537
self.extra_args = [[
36-
"-dustrelayfee=0", "-walletrejectlongchains=0", "[email protected]"
38+
"-dustrelayfee=0", "-walletrejectlongchains=0"
3739
]] * self.num_nodes
3840
self.setup_clean_chain = True
3941
self.supports_cli = False

Diff for: test/functional/wallet_bumpfee.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ def add_options(self, parser):
5555
def set_test_params(self):
5656
self.num_nodes = 2
5757
self.setup_clean_chain = True
58+
# whitelist peers to speed up tx relay / mempool sync
59+
self.noban_tx_relay = True
5860
self.extra_args = [[
5961
"-walletrbf={}".format(i),
6062
"-mintxfee=0.00002",
6163
"-addresstype=bech32",
62-
6364
] for i in range(self.num_nodes)]
6465

6566
def skip_test_if_missing_module(self):

Diff for: test/functional/wallet_fundrawtransaction.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ def add_options(self, parser):
4545
def set_test_params(self):
4646
self.num_nodes = 4
4747
self.setup_clean_chain = True
48-
# This test isn't testing tx relay. Set whitelist on the peers for
49-
# instant tx relay.
50-
self.extra_args = [['[email protected]']] * self.num_nodes
48+
# whitelist peers to speed up tx relay / mempool sync
49+
self.noban_tx_relay = True
5150
self.rpc_timeout = 90 # to prevent timeouts in `test_transaction_too_large`
5251

5352
def skip_test_if_missing_module(self):

Diff for: test/functional/wallet_groups.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def add_options(self, parser):
2222
def set_test_params(self):
2323
self.setup_clean_chain = True
2424
self.num_nodes = 5
25+
# whitelist peers to speed up tx relay / mempool sync
26+
self.noban_tx_relay = True
2527
self.extra_args = [
2628
[],
2729
[],
@@ -31,7 +33,6 @@ def set_test_params(self):
3133
]
3234

3335
for args in self.extra_args:
34-
args.append("[email protected]") # whitelist peers to speed up tx relay / mempool sync
3536
args.append(f"-paytxfee={20 * 1e3 / 1e8}") # apply feerate of 20 sats/vB across all nodes
3637

3738
self.rpc_timeout = 480

Diff for: test/functional/wallet_hd.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def set_test_params(self):
2323
self.num_nodes = 2
2424
self.extra_args = [[], ['-keypool=0']]
2525
# whitelist peers to speed up tx relay / mempool sync
26-
for args in self.extra_args:
27-
args.append("[email protected]")
26+
self.noban_tx_relay = True
2827

2928
self.supports_cli = False
3029

Diff for: test/functional/wallet_import_rescan.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def set_test_params(self):
160160
self.num_nodes = 2 + len(IMPORT_NODES)
161161
self.supports_cli = False
162162
self.rpc_timeout = 120
163+
# whitelist peers to speed up tx relay / mempool sync
164+
self.noban_tx_relay = True
163165

164166
def skip_test_if_missing_module(self):
165167
self.skip_if_no_wallet()
@@ -177,7 +179,7 @@ def setup_network(self):
177179
self.import_deterministic_coinbase_privkeys()
178180
self.stop_nodes()
179181

180-
self.start_nodes(extra_args=[["[email protected]"]] * self.num_nodes)
182+
self.start_nodes()
181183
for i in range(1, self.num_nodes):
182184
self.connect_nodes(i, 0)
183185

Diff for: test/functional/wallet_importdescriptors.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ def add_options(self, parser):
3636

3737
def set_test_params(self):
3838
self.num_nodes = 2
39+
# whitelist peers to speed up tx relay / mempool sync
40+
self.noban_tx_relay = True
3941
self.extra_args = [["-addresstype=legacy"],
4042
["-addresstype=bech32", "-keypool=5"]
4143
]
42-
# whitelist peers to speed up tx relay / mempool sync
43-
for args in self.extra_args:
44-
args.append("[email protected]")
4544
self.setup_clean_chain = True
4645
self.wallet_names = []
4746

Diff for: test/functional/wallet_listreceivedby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def add_options(self, parser):
2222
def set_test_params(self):
2323
self.num_nodes = 2
2424
# whitelist peers to speed up tx relay / mempool sync
25-
self.extra_args = [["[email protected]"]] * self.num_nodes
25+
self.noban_tx_relay = True
2626

2727
def skip_test_if_missing_module(self):
2828
self.skip_if_no_wallet()

Diff for: test/functional/wallet_listsinceblock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def set_test_params(self):
2626
self.num_nodes = 4
2727
self.setup_clean_chain = True
2828
# whitelist peers to speed up tx relay / mempool sync
29-
self.extra_args = [["[email protected]"]] * self.num_nodes
29+
self.noban_tx_relay = True
3030

3131
def skip_test_if_missing_module(self):
3232
self.skip_if_no_wallet()

0 commit comments

Comments
 (0)