@@ -27,9 +27,20 @@ def set_test_params(self):
27
27
self .wallet_names = []
28
28
self .disable_autoconnect = False
29
29
30
+ # Overridden to avoid attempt to sync not yet started nodes.
31
+ def setup_network (self ):
32
+ self .setup_nodes ()
33
+
34
+ # Overriden to not start nodes automatically - doing so is the
35
+ # responsibility of each test function.
36
+ def setup_nodes (self ):
37
+ self .add_nodes (self .num_nodes , self .extra_args )
38
+ # Ensure a log file exists as TestNode.assert_debug_log() expects it.
39
+ self .nodes [0 ].debug_log_path .parent .mkdir ()
40
+ self .nodes [0 ].debug_log_path .touch ()
41
+
30
42
def test_config_file_parser (self ):
31
43
self .log .info ('Test config file parser' )
32
- self .stop_node (0 )
33
44
34
45
# Check that startup fails if conf= is set in bitcoin.conf or in an included conf file
35
46
bad_conf_file_path = self .nodes [0 ].datadir_path / "bitcoin_bad.conf"
@@ -162,12 +173,11 @@ def test_invalid_command_line_options(self):
162
173
)
163
174
164
175
def test_log_buffer (self ):
165
- self .stop_node (0 )
166
176
with self .nodes [0 ].assert_debug_log (expected_msgs = ['Warning: parsed potentially confusing double-negative -connect=0\n ' ]):
167
177
self .start_node (0 , extra_args = ['-noconnect=0' ])
178
+ self .stop_node (0 )
168
179
169
180
def test_args_log (self ):
170
- self .stop_node (0 )
171
181
self .log .info ('Test config args logging' )
172
182
with self .nodes [0 ].assert_debug_log (
173
183
expected_msgs = [
@@ -196,10 +206,10 @@ def test_args_log(self):
196
206
'-rpcuser=secret-rpcuser' ,
197
207
'-torpassword=secret-torpassword' ,
198
208
])
209
+ self .stop_node (0 )
199
210
200
211
def test_networkactive (self ):
201
212
self .log .info ('Test -networkactive option' )
202
- self .stop_node (0 )
203
213
with self .nodes [0 ].assert_debug_log (expected_msgs = ['SetNetworkActive: true\n ' ]):
204
214
self .start_node (0 )
205
215
@@ -222,16 +232,12 @@ def test_networkactive(self):
222
232
self .stop_node (0 )
223
233
with self .nodes [0 ].assert_debug_log (expected_msgs = ['SetNetworkActive: false\n ' ]):
224
234
self .start_node (0 , extra_args = ['-nonetworkactive=1' ])
235
+ self .stop_node (0 )
225
236
226
237
def test_seed_peers (self ):
227
238
self .log .info ('Test seed peers' )
228
239
default_data_dir = self .nodes [0 ].datadir_path
229
240
peer_dat = default_data_dir / 'peers.dat'
230
- # Only regtest has no fixed seeds. To avoid connections to random
231
- # nodes, regtest is the only network where it is safe to enable
232
- # -fixedseeds in tests
233
- util .assert_equal (self .nodes [0 ].getblockchaininfo ()['chain' ],'regtest' )
234
- self .stop_node (0 )
235
241
236
242
# No peers.dat exists and -dnsseed=1
237
243
# We expect the node will use DNS Seeds, but Regtest mode does not have
@@ -248,6 +254,12 @@ def test_seed_peers(self):
248
254
timeout = 10 ,
249
255
):
250
256
self .start_node (0 , extra_args = ['-dnsseed=1' , '-fixedseeds=1' , f'-mocktime={ start } ' ])
257
+
258
+ # Only regtest has no fixed seeds. To avoid connections to random
259
+ # nodes, regtest is the only network where it is safe to enable
260
+ # -fixedseeds in tests
261
+ util .assert_equal (self .nodes [0 ].getblockchaininfo ()['chain' ],'regtest' )
262
+
251
263
with self .nodes [0 ].assert_debug_log (expected_msgs = [
252
264
"Adding fixed seeds as 60 seconds have passed and addrman is empty" ,
253
265
]):
@@ -294,13 +306,13 @@ def test_seed_peers(self):
294
306
"Adding fixed seeds as 60 seconds have passed and addrman is empty" ,
295
307
]):
296
308
self .nodes [0 ].setmocktime (start + 65 )
309
+ self .stop_node (0 )
297
310
298
311
def test_connect_with_seednode (self ):
299
312
self .log .info ('Test -connect with -seednode' )
300
313
seednode_ignored = ['-seednode is ignored when -connect is used\n ' ]
301
314
dnsseed_ignored = ['-dnsseed is ignored when -connect is used and -proxy is specified\n ' ]
302
315
addcon_thread_started = ['addcon thread start\n ' ]
303
- self .stop_node (0 )
304
316
305
317
# When -connect is supplied, expanding addrman via getaddr calls to ADDR_FETCH(-seednode)
306
318
# nodes is irrelevant and -seednode is ignored.
@@ -325,6 +337,7 @@ def test_connect_with_seednode(self):
325
337
with self .nodes [0 ].assert_debug_log (expected_msgs = addcon_thread_started ,
326
338
unexpected_msgs = seednode_ignored ):
327
339
self .restart_node (0 , extra_args = [connect_arg , '-seednode=fakeaddress2' ])
340
+ self .stop_node (0 )
328
341
329
342
def test_ignored_conf (self ):
330
343
self .log .info ('Test error is triggered when the datadir in use contains a bitcoin.conf file that would be ignored '
0 commit comments