From 75bb7ec0229055f07a91bdfa0229a128c7aa7f35 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Sat, 4 Jan 2020 12:21:16 +0100 Subject: [PATCH] A few optimizations/speedups for Dash related tests (#3268) * Avoid unnecessary connections in dip3-deterministicmns.py This saves ~15 seconds * Generate more blocks per generate() call * Use -vbparams to activate dip8 faster in tests Avoids generating/syncing many unnecessary blocks --- test/functional/dip3-deterministicmns.py | 12 +++++------- test/functional/dip4-coinbasemerkleroots.py | 1 + test/functional/llmq-chainlocks.py | 1 + test/functional/llmq-dkgerrors.py | 1 + test/functional/llmq-is-cl-conflicts.py | 1 + test/functional/llmq-is-retroactive.py | 1 + test/functional/test_framework/test_framework.py | 8 +++++++- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/functional/dip3-deterministicmns.py b/test/functional/dip3-deterministicmns.py index 2e7a433040..58ed13c9cc 100755 --- a/test/functional/dip3-deterministicmns.py +++ b/test/functional/dip3-deterministicmns.py @@ -37,7 +37,7 @@ class DIP3Test(BitcoinTestFramework): self.start_node(0, extra_args=self.extra_args) for i in range(1, self.num_nodes): if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None: - connect_nodes_bi(self.nodes, 0, i) + connect_nodes(self.nodes[i], 0) def stop_controller_node(self): self.log.info("stopping controller node") @@ -50,7 +50,7 @@ class DIP3Test(BitcoinTestFramework): def run_test(self): self.log.info("funding controller node") while self.nodes[0].getbalance() < (self.num_initial_mn + 3) * 1000: - self.nodes[0].generate(1) # generate enough for collaterals + self.nodes[0].generate(10) # generate enough for collaterals self.log.info("controller node has {} dash".format(self.nodes[0].getbalance())) # Make sure we're below block 135 (which activates dip3) @@ -66,8 +66,8 @@ class DIP3Test(BitcoinTestFramework): mns.append(before_dip3_mn) # block 150 starts enforcing DIP3 MN payments - while self.nodes[0].getblockcount() < 150: - self.nodes[0].generate(1) + self.nodes[0].generate(150 - self.nodes[0].getblockcount()) + assert(self.nodes[0].getblockcount() == 150) self.log.info("mining final block for DIP3 activation") self.nodes[0].generate(1) @@ -263,10 +263,8 @@ class DIP3Test(BitcoinTestFramework): extra_args = ['-masternodeblsprivkey=%s' % mn.blsMnkey] self.start_node(mn.idx, extra_args = self.extra_args + extra_args) force_finish_mnsync(self.nodes[mn.idx]) - for i in range(0, len(self.nodes)): - if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None and i != mn.idx: - connect_nodes_bi(self.nodes, mn.idx, i) mn.node = self.nodes[mn.idx] + connect_nodes(mn.node, 0) self.sync_all() def spend_mn_collateral(self, mn, with_dummy_input_output=False): diff --git a/test/functional/dip4-coinbasemerkleroots.py b/test/functional/dip4-coinbasemerkleroots.py index 10e6202e16..f0c15a536e 100755 --- a/test/functional/dip4-coinbasemerkleroots.py +++ b/test/functional/dip4-coinbasemerkleroots.py @@ -39,6 +39,7 @@ class TestNode(NodeConnCB): class LLMQCoinbaseCommitmentsTest(DashTestFramework): def set_test_params(self): self.set_dash_test_params(6, 5, fast_dip3_enforcement=True) + self.set_dash_dip8_activation(200) def run_test(self): self.test_node = TestNode() diff --git a/test/functional/llmq-chainlocks.py b/test/functional/llmq-chainlocks.py index 2ebb832861..394d6d7c22 100755 --- a/test/functional/llmq-chainlocks.py +++ b/test/functional/llmq-chainlocks.py @@ -19,6 +19,7 @@ Checks LLMQs based ChainLocks class LLMQChainLocksTest(DashTestFramework): def set_test_params(self): self.set_dash_test_params(6, 5, fast_dip3_enforcement=True) + self.set_dash_dip8_activation(10) def run_test(self): diff --git a/test/functional/llmq-dkgerrors.py b/test/functional/llmq-dkgerrors.py index 27d4287a14..89903a7fb5 100755 --- a/test/functional/llmq-dkgerrors.py +++ b/test/functional/llmq-dkgerrors.py @@ -16,6 +16,7 @@ Simulate and check DKG errors class LLMQDKGErrors(DashTestFramework): def set_test_params(self): self.set_dash_test_params(6, 5, [["-whitelist=127.0.0.1"]] * 6, fast_dip3_enforcement=True) + self.set_dash_dip8_activation(10) def run_test(self): diff --git a/test/functional/llmq-is-cl-conflicts.py b/test/functional/llmq-is-cl-conflicts.py index 45546dc378..0d1689f168 100755 --- a/test/functional/llmq-is-cl-conflicts.py +++ b/test/functional/llmq-is-cl-conflicts.py @@ -49,6 +49,7 @@ class TestNode(NodeConnCB): class LLMQ_IS_CL_Conflicts(DashTestFramework): def set_test_params(self): self.set_dash_test_params(6, 5, fast_dip3_enforcement=True) + self.set_dash_dip8_activation(10) #disable_mocktime() def run_test(self): diff --git a/test/functional/llmq-is-retroactive.py b/test/functional/llmq-is-retroactive.py index 90ee7999e5..41d4688679 100755 --- a/test/functional/llmq-is-retroactive.py +++ b/test/functional/llmq-is-retroactive.py @@ -22,6 +22,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework): def set_test_params(self): # -whitelist is needed to avoid the trickling logic on node0 self.set_dash_test_params(6, 5, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"], ["-minrelaytxfee=0.001"]], fast_dip3_enforcement=True) + self.set_dash_dip8_activation(10) def run_test(self): while self.nodes[0].getblockchaininfo()["bip9_softforks"]["dip0008"]["status"] != "active": diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 95d1d95d04..c196a9935a 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -499,6 +499,12 @@ class DashTestFramework(BitcoinTestFramework): for i in range(0, num_nodes): self.extra_args[i] += ["-dip3params=30:50"] + def set_dash_dip8_activation(self, activate_after_block): + window = int((activate_after_block + 2) / 3) + threshold = int((window + 1) / 2) + for i in range(0, self.num_nodes): + self.extra_args[i].append("-vbparams=dip0008:0:999999999999:%d:%d" % (window, threshold)) + def create_simple_node(self): idx = len(self.nodes) self.add_nodes(1, extra_args=[self.extra_args[idx]]) @@ -617,7 +623,7 @@ class DashTestFramework(BitcoinTestFramework): while self.nodes[0].getbalance() < required_balance: self.bump_mocktime(1) set_node_times(self.nodes, self.mocktime) - self.nodes[0].generate(1) + self.nodes[0].generate(10) num_simple_nodes = self.num_nodes - self.mn_count - 1 self.log.info("Creating and starting %s simple nodes", num_simple_nodes) for i in range(0, num_simple_nodes):