Skip to content

Commit 2972e84

Browse files
committed
test: removed duplicated code from dynamically_initialize_datadir with dash.conf preparation
1 parent 521d92f commit 2972e84

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
check_json_precision,
4949
copy_datadir,
5050
force_finish_mnsync,
51-
get_chain_conf_names,
5251
get_datadir_path,
5352
initialize_datadir,
5453
p2p_port,
5554
set_node_times,
5655
satoshi_round,
5756
softfork_active,
5857
wait_until_helper,
59-
get_chain_folder, rpc_port,
58+
get_chain_folder,
59+
write_config,
6060
)
6161

6262

@@ -607,7 +607,7 @@ def add_dynamically_node(self, extra_args=None, *, rpchost=None, binary=None):
607607
return t_node
608608

609609
# TODO: move it to DashTestFramework where it belongs
610-
def dynamically_initialize_datadir(self, node_p2p_port, node_rpc_port):
610+
def dynamically_initialize_datadir(self, mnidx):
611611
source_data_dir = get_datadir_path(self.options.tmpdir, 0) # use node0 as a source
612612
new_data_dir = get_datadir_path(self.options.tmpdir, len(self.nodes))
613613

@@ -624,33 +624,15 @@ def dynamically_initialize_datadir(self, node_p2p_port, node_rpc_port):
624624
if entry not in ['chainstate', 'blocks', 'indexes', 'evodb']:
625625
os.remove(os.path.join(new_data_dir, self.chain, entry))
626626

627-
(chain_name_conf_arg, chain_name_conf_arg_value, chain_name_conf_section) = get_chain_conf_names(self.chain)
628-
629-
with open(os.path.join(new_data_dir, "dash.conf"), 'w', encoding='utf8') as f:
630-
f.write("{}={}\n".format(chain_name_conf_arg, chain_name_conf_arg_value))
631-
f.write("[{}]\n".format(chain_name_conf_section))
632-
f.write("port=" + str(node_p2p_port) + "\n")
633-
f.write("rpcport=" + str(node_rpc_port) + "\n")
634-
f.write("server=1\n")
635-
f.write("rpcdoccheck=1\n")
636-
f.write("fallbackfee=0.00001\n")
637-
f.write("server=1\n")
638-
f.write("keypool=1\n")
639-
f.write("discover=0\n")
640-
f.write("dnsseed=0\n")
641-
f.write("fixedseeds=0\n")
642-
f.write("listenonion=0\n")
643-
f.write("peertimeout=999999999\n")
644-
f.write("printtoconsole=0\n")
645-
f.write("upnp=0\n")
646-
f.write("natpmp=0\n")
647-
f.write("shrinkdebugfile=0\n")
648-
f.write("unsafesqlitesync=1\n")
649-
f.write("dip3params=2:2\n")
650-
f.write(f"testactivationheight=v20@{self.v20_height}\n")
651-
f.write(f"testactivationheight=mn_rr@{self.mn_rr_height}\n")
652-
os.makedirs(os.path.join(new_data_dir, 'stderr'), exist_ok=True)
653-
os.makedirs(os.path.join(new_data_dir, 'stdout'), exist_ok=True)
627+
write_config(os.path.join(new_data_dir, "dash.conf"), extra_config=
628+
"dip3params=2:2\n"
629+
f"testactivationheight=v20@{self.v20_height}\n"
630+
f"testactivationheight=mn_rr@{self.mn_rr_height}\n",
631+
n=mnidx, chain=self.chain, disable_autoconnect=self.disable_autoconnect)
632+
633+
os.makedirs(os.path.join(new_data_dir, 'stderr'), exist_ok=True)
634+
os.makedirs(os.path.join(new_data_dir, 'stdout'), exist_ok=True)
635+
return new_data_dir
654636

655637
def start_node(self, i, *args, **kwargs):
656638
"""Start a dashd"""
@@ -1600,7 +1582,6 @@ def dynamically_add_masternode(self, evo=False, rnd=None, should_be_rejected=Fal
16001582
mn_idx = len(self.nodes)
16011583

16021584
node_p2p_port = p2p_port(mn_idx)
1603-
node_rpc_port = rpc_port(mn_idx)
16041585

16051586
protx_success = False
16061587
try:
@@ -1615,7 +1596,7 @@ def dynamically_add_masternode(self, evo=False, rnd=None, should_be_rejected=Fal
16151596
# nothing to do
16161597
return None
16171598

1618-
self.dynamically_initialize_datadir(node_p2p_port, node_rpc_port)
1599+
self.dynamically_initialize_datadir(mn_idx)
16191600
node_info = self.add_dynamically_node(self.extra_args[0])
16201601

16211602
args = ['-masternodeblsprivkey=%s' % created_mn_info.keyOperator] + node_info.extra_args

0 commit comments

Comments
 (0)