From fa4ba4d169ac3250710100de2dcf9cd2ec7ff173 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 21 Nov 2024 16:57:44 +0700 Subject: [PATCH] refactor: moved functions do_connect, remove_masternode closer to theirs usages --- .../feature_dip4_coinbasemerkleroots.py | 11 +++++++++++ .../test_framework/test_framework.py | 18 ++---------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/test/functional/feature_dip4_coinbasemerkleroots.py b/test/functional/feature_dip4_coinbasemerkleroots.py index ac45de1176..d8e05cb2e0 100755 --- a/test/functional/feature_dip4_coinbasemerkleroots.py +++ b/test/functional/feature_dip4_coinbasemerkleroots.py @@ -45,6 +45,17 @@ class LLMQCoinbaseCommitmentsTest(DashTestFramework): def set_test_params(self): self.extra_args = [[ f'-testactivationheight=dip0008@{DIP0008_HEIGHT}', "-vbparams=testdummy:999999999999:999999999999" ]] * 4 self.set_dash_test_params(4, 3, extra_args = self.extra_args) + + def remove_masternode(self, idx): + mn = self.mninfo[idx] + rawtx = self.nodes[0].createrawtransaction([{"txid": mn.collateral_txid, "vout": mn.collateral_vout}], {self.nodes[0].getnewaddress(): 999.9999}) + rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx) + self.nodes[0].sendrawtransaction(rawtx["hex"]) + self.generate(self.nodes[0], 1) + self.mninfo.remove(mn) + + self.log.info("Removed masternode %d", idx) + def run_test(self): # No IS or Chainlocks in this test self.bump_mocktime(1) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 3ccf819fd9..ff0fc848d2 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1431,16 +1431,6 @@ class DashTestFramework(BitcoinTestFramework): self.log.info("Prepared MN %d: collateral_txid=%s, collateral_vout=%d, protxHash=%s" % (idx, txid, collateral_vout, proTxHash)) - def remove_masternode(self, idx): - mn = self.mninfo[idx] - rawtx = self.nodes[0].createrawtransaction([{"txid": mn.collateral_txid, "vout": mn.collateral_vout}], {self.nodes[0].getnewaddress(): 999.9999}) - rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx) - self.nodes[0].sendrawtransaction(rawtx["hex"]) - self.generate(self.nodes[0], 1) - self.mninfo.remove(mn) - - self.log.info("Removed masternode %d", idx) - def prepare_datadirs(self): # stop faucet node so that we can copy the datadir self.stop_node(0) @@ -1461,10 +1451,6 @@ class DashTestFramework(BitcoinTestFramework): self.add_nodes(self.mn_count) executor = ThreadPoolExecutor(max_workers=20) - def do_connect(idx): - # Connect to the control node only, masternodes should take care of intra-quorum connections themselves - self.connect_nodes(self.mninfo[idx].nodeIdx, 0) - jobs = [] # start up nodes in parallel @@ -1479,9 +1465,9 @@ class DashTestFramework(BitcoinTestFramework): executor.shutdown() - # connect nodes + # Connect to the control node only, masternodes should take care of intra-quorum connections themselves for idx in range(0, self.mn_count): - do_connect(idx) + self.connect_nodes(self.mninfo[idx].nodeIdx, 0) def start_masternode(self, mninfo, extra_args=None): args = ['-masternodeblsprivkey=%s' % mninfo.keyOperator] + self.extra_args[mninfo.nodeIdx]