refactor: moved functions do_connect, remove_masternode closer to theirs usages

This commit is contained in:
Konstantin Akimov 2024-11-21 16:57:44 +07:00
parent 8eb5d852c7
commit fa4ba4d169
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 13 additions and 16 deletions

View File

@ -45,6 +45,17 @@ class LLMQCoinbaseCommitmentsTest(DashTestFramework):
def set_test_params(self): def set_test_params(self):
self.extra_args = [[ f'-testactivationheight=dip0008@{DIP0008_HEIGHT}', "-vbparams=testdummy:999999999999:999999999999" ]] * 4 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) 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): def run_test(self):
# No IS or Chainlocks in this test # No IS or Chainlocks in this test
self.bump_mocktime(1) self.bump_mocktime(1)

View File

@ -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)) 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): def prepare_datadirs(self):
# stop faucet node so that we can copy the datadir # stop faucet node so that we can copy the datadir
self.stop_node(0) self.stop_node(0)
@ -1461,10 +1451,6 @@ class DashTestFramework(BitcoinTestFramework):
self.add_nodes(self.mn_count) self.add_nodes(self.mn_count)
executor = ThreadPoolExecutor(max_workers=20) 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 = [] jobs = []
# start up nodes in parallel # start up nodes in parallel
@ -1479,9 +1465,9 @@ class DashTestFramework(BitcoinTestFramework):
executor.shutdown() 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): 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): def start_masternode(self, mninfo, extra_args=None):
args = ['-masternodeblsprivkey=%s' % mninfo.keyOperator] + self.extra_args[mninfo.nodeIdx] args = ['-masternodeblsprivkey=%s' % mninfo.keyOperator] + self.extra_args[mninfo.nodeIdx]