Skip to content

Commit

Permalink
refactor: Introduce get_chain_conf_names
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Nov 1, 2024
1 parent 519966e commit efc8c99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
15 changes: 2 additions & 13 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
check_json_precision,
copy_datadir,
force_finish_mnsync,
get_chain_conf_names,
get_datadir_path,
initialize_datadir,
p2p_port,
Expand Down Expand Up @@ -610,19 +611,7 @@ def dynamically_initialize_datadir(self, node_p2p_port, node_rpc_port):
if entry not in ['chainstate', 'blocks', 'indexes', 'evodb']:
os.remove(os.path.join(new_data_dir, self.chain, entry))

# Translate chain name to config name
if self.chain == 'testnet3':
chain_name_conf_arg = 'testnet'
chain_name_conf_section = 'test'
chain_name_conf_arg_value = '1'
elif self.chain == 'devnet':
chain_name_conf_arg = 'devnet'
chain_name_conf_section = 'devnet'
chain_name_conf_arg_value = 'devnet1'
else:
chain_name_conf_arg = self.chain
chain_name_conf_section = self.chain
chain_name_conf_arg_value = '1'
(chain_name_conf_arg, chain_name_conf_arg_value, chain_name_conf_section) = get_chain_conf_names(self.chain)

with open(os.path.join(new_data_dir, "dash.conf"), 'w', encoding='utf8') as f:
f.write("{}={}\n".format(chain_name_conf_arg, chain_name_conf_arg_value))
Expand Down
32 changes: 19 additions & 13 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,19 +381,7 @@ def initialize_datadir(dirname, n, chain):


def write_config(config_path, *, n, chain, extra_config=""):
# Translate chain subdirectory name to config name
if chain == 'testnet3':
chain_name_conf_arg = 'testnet'
chain_name_conf_section = 'test'
chain_name_conf_arg_value = '1'
elif chain == 'devnet':
chain_name_conf_arg = 'devnet'
chain_name_conf_section = 'devnet'
chain_name_conf_arg_value = 'devnet1'
else:
chain_name_conf_arg = chain
chain_name_conf_section = chain
chain_name_conf_arg_value = '1'
(chain_name_conf_arg, chain_name_conf_arg_value, chain_name_conf_section) = get_chain_conf_names(chain)
with open(config_path, 'w', encoding='utf8') as f:
if chain_name_conf_arg:
f.write("{}={}\n".format(chain_name_conf_arg, chain_name_conf_arg_value))
Expand Down Expand Up @@ -494,6 +482,24 @@ def get_chain_folder(datadir, chain):
pass
return chain

def get_chain_conf_names(chain):
"""
Translate chain name to config names
"""
if chain == 'testnet3':
arg = 'testnet'
value = '1'
section = 'test'
elif chain == 'devnet':
arg = 'devnet'
value = 'devnet1'
section = 'devnet'
else:
arg = chain
value = '1'
section = chain
return (arg, value, section)

def get_bip9_details(node, key):
"""Return extra info about bip9 softfork"""
return node.getblockchaininfo()['softforks'][key]['bip9']
Expand Down

0 comments on commit efc8c99

Please sign in to comment.