Skip to content

Commit

Permalink
test: Assume node is running in subtests
Browse files Browse the repository at this point in the history
Every (sub)test in the framework assumes the node is running, except for
the (sub)tests in this file. Remove that confusion by stopping the node
at the start of every subtest, instead of at the end.
  • Loading branch information
MarcoFalke committed Feb 21, 2021
1 parent 828bb77 commit fa1b713
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/functional/feature_config_args.py
Expand Up @@ -19,7 +19,7 @@ def set_test_params(self):
self.wallet_names = []

def test_config_file_parser(self):
# Assume node is stopped
self.stop_node(0)

inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
Expand Down Expand Up @@ -89,11 +89,12 @@ def test_invalid_command_line_options(self):
)

def test_log_buffer(self):
self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['Warning: parsed potentially confusing double-negative -connect=0\n']):
self.start_node(0, extra_args=['-noconnect=0'])
self.stop_node(0)

def test_args_log(self):
self.stop_node(0)
self.log.info('Test config args logging')
with self.nodes[0].assert_debug_log(
expected_msgs=[
Expand All @@ -120,37 +121,37 @@ def test_args_log(self):
'-rpcuser=secret-rpcuser',
'-torpassword=secret-torpassword',
])
self.stop_node(0)

def test_networkactive(self):
self.log.info('Test -networkactive option')
self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: true\n']):
self.start_node(0)
self.stop_node(0)

self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: true\n']):
self.start_node(0, extra_args=['-networkactive'])
self.stop_node(0)

self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: true\n']):
self.start_node(0, extra_args=['-networkactive=1'])
self.stop_node(0)

self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: false\n']):
self.start_node(0, extra_args=['-networkactive=0'])
self.stop_node(0)

self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: false\n']):
self.start_node(0, extra_args=['-nonetworkactive'])
self.stop_node(0)

self.stop_node(0)
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: false\n']):
self.start_node(0, extra_args=['-nonetworkactive=1'])
self.stop_node(0)

def test_seed_peers(self):
self.log.info('Test seed peers')
default_data_dir = self.nodes[0].datadir
self.stop_node(0)

# No peers.dat exists and -dnsseed=1
# We expect the node will use DNS Seeds, but Regtest mode has 0 DNS seeds
Expand Down Expand Up @@ -201,12 +202,9 @@ def test_seed_peers(self):
with self.nodes[0].assert_debug_log(expected_msgs=[
"Adding fixed seeds as 60 seconds have passed and addrman is empty"]):
self.nodes[0].setmocktime(start + 65)
self.stop_node(0)


def run_test(self):
self.stop_node(0)

self.test_log_buffer()
self.test_args_log()
self.test_seed_peers()
Expand Down

0 comments on commit fa1b713

Please sign in to comment.