@@ -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"
@@ -155,12 +166,11 @@ def test_invalid_command_line_options(self):
155
166
)
156
167
157
168
def test_log_buffer (self ):
158
- self .stop_node (0 )
159
169
with self .nodes [0 ].assert_debug_log (expected_msgs = ['Warning: parsed potentially confusing double-negative -connect=0\n ' ]):
160
170
self .start_node (0 , extra_args = ['-noconnect=0' ])
171
+ self .stop_node (0 )
161
172
162
173
def test_args_log (self ):
163
- self .stop_node (0 )
164
174
self .log .info ('Test config args logging' )
165
175
with self .nodes [0 ].assert_debug_log (
166
176
expected_msgs = [
@@ -189,10 +199,10 @@ def test_args_log(self):
189
199
'-rpcuser=secret-rpcuser' ,
190
200
'-torpassword=secret-torpassword' ,
191
201
])
202
+ self .stop_node (0 )
192
203
193
204
def test_networkactive (self ):
194
205
self .log .info ('Test -networkactive option' )
195
- self .stop_node (0 )
196
206
with self .nodes [0 ].assert_debug_log (expected_msgs = ['SetNetworkActive: true\n ' ]):
197
207
self .start_node (0 )
198
208
@@ -215,16 +225,12 @@ def test_networkactive(self):
215
225
self .stop_node (0 )
216
226
with self .nodes [0 ].assert_debug_log (expected_msgs = ['SetNetworkActive: false\n ' ]):
217
227
self .start_node (0 , extra_args = ['-nonetworkactive=1' ])
228
+ self .stop_node (0 )
218
229
219
230
def test_seed_peers (self ):
220
231
self .log .info ('Test seed peers' )
221
232
default_data_dir = self .nodes [0 ].datadir_path
222
233
peer_dat = default_data_dir / 'peers.dat'
223
- # Only regtest has no fixed seeds. To avoid connections to random
224
- # nodes, regtest is the only network where it is safe to enable
225
- # -fixedseeds in tests
226
- util .assert_equal (self .nodes [0 ].getblockchaininfo ()['chain' ],'regtest' )
227
- self .stop_node (0 )
228
234
229
235
# No peers.dat exists and -dnsseed=1
230
236
# We expect the node will use DNS Seeds, but Regtest mode does not have
@@ -241,6 +247,12 @@ def test_seed_peers(self):
241
247
timeout = 10 ,
242
248
):
243
249
self .start_node (0 , extra_args = ['-dnsseed=1' , '-fixedseeds=1' , f'-mocktime={ start } ' ])
250
+
251
+ # Only regtest has no fixed seeds. To avoid connections to random
252
+ # nodes, regtest is the only network where it is safe to enable
253
+ # -fixedseeds in tests
254
+ util .assert_equal (self .nodes [0 ].getblockchaininfo ()['chain' ],'regtest' )
255
+
244
256
with self .nodes [0 ].assert_debug_log (expected_msgs = [
245
257
"Adding fixed seeds as 60 seconds have passed and addrman is empty" ,
246
258
]):
@@ -287,13 +299,13 @@ def test_seed_peers(self):
287
299
"Adding fixed seeds as 60 seconds have passed and addrman is empty" ,
288
300
]):
289
301
self .nodes [0 ].setmocktime (start + 65 )
302
+ self .stop_node (0 )
290
303
291
304
def test_connect_with_seednode (self ):
292
305
self .log .info ('Test -connect with -seednode' )
293
306
seednode_ignored = ['-seednode is ignored when -connect is used\n ' ]
294
307
dnsseed_ignored = ['-dnsseed is ignored when -connect is used and -proxy is specified\n ' ]
295
308
addcon_thread_started = ['addcon thread start\n ' ]
296
- self .stop_node (0 )
297
309
298
310
# When -connect is supplied, expanding addrman via getaddr calls to ADDR_FETCH(-seednode)
299
311
# nodes is irrelevant and -seednode is ignored.
@@ -318,6 +330,7 @@ def test_connect_with_seednode(self):
318
330
with self .nodes [0 ].assert_debug_log (expected_msgs = addcon_thread_started ,
319
331
unexpected_msgs = seednode_ignored ):
320
332
self .restart_node (0 , extra_args = [connect_arg , '-seednode=fakeaddress2' ])
333
+ self .stop_node (0 )
321
334
322
335
def test_ignored_conf (self ):
323
336
self .log .info ('Test error is triggered when the datadir in use contains a bitcoin.conf file that would be ignored '
0 commit comments