From 261ba454131234e4d55e2aafdaa171acaffdb5b2 Mon Sep 17 00:00:00 2001
From: UdjinM6 <UdjinM6@users.noreply.github.com>
Date: Thu, 5 Dec 2019 17:26:41 +0300
Subject: [PATCH] Tests: Allow specifying different cmd-line params for each
 masternode

---
 test/functional/dip4-coinbasemerkleroots.py    |  2 +-
 test/functional/llmq-chainlocks.py             |  2 +-
 test/functional/llmq-dkgerrors.py              |  2 +-
 test/functional/llmq-is-cl-conflicts.py        |  2 +-
 test/functional/llmq-signing.py                |  2 +-
 test/functional/llmq-simplepose.py             |  2 +-
 test/functional/p2p-instantsend.py             |  2 +-
 .../test_framework/test_framework.py           | 18 ++++++++++--------
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/test/functional/dip4-coinbasemerkleroots.py b/test/functional/dip4-coinbasemerkleroots.py
index 1734f11c130b..10e6202e16fa 100755
--- a/test/functional/dip4-coinbasemerkleroots.py
+++ b/test/functional/dip4-coinbasemerkleroots.py
@@ -38,7 +38,7 @@ def getmnlistdiff(self, baseBlockHash, blockHash):
 
 class LLMQCoinbaseCommitmentsTest(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(6, 5, [], fast_dip3_enforcement=True)
+        self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)
 
     def run_test(self):
         self.test_node = TestNode()
diff --git a/test/functional/llmq-chainlocks.py b/test/functional/llmq-chainlocks.py
index 0bd2d09722d7..b08c69dd57b4 100755
--- a/test/functional/llmq-chainlocks.py
+++ b/test/functional/llmq-chainlocks.py
@@ -18,7 +18,7 @@
 
 class LLMQChainLocksTest(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(6, 5, [], fast_dip3_enforcement=True)
+        self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)
 
     def run_test(self):
 
diff --git a/test/functional/llmq-dkgerrors.py b/test/functional/llmq-dkgerrors.py
index f6f109e744dd..27d4287a1447 100755
--- a/test/functional/llmq-dkgerrors.py
+++ b/test/functional/llmq-dkgerrors.py
@@ -15,7 +15,7 @@
 
 class LLMQDKGErrors(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(6, 5, ["-whitelist=127.0.0.1"], fast_dip3_enforcement=True)
+        self.set_dash_test_params(6, 5, [["-whitelist=127.0.0.1"]] * 6, fast_dip3_enforcement=True)
 
     def run_test(self):
 
diff --git a/test/functional/llmq-is-cl-conflicts.py b/test/functional/llmq-is-cl-conflicts.py
index 964275b0891a..45546dc378dd 100755
--- a/test/functional/llmq-is-cl-conflicts.py
+++ b/test/functional/llmq-is-cl-conflicts.py
@@ -48,7 +48,7 @@ def on_getdata(self, conn, message):
 
 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_test_params(6, 5, fast_dip3_enforcement=True)
         #disable_mocktime()
 
     def run_test(self):
diff --git a/test/functional/llmq-signing.py b/test/functional/llmq-signing.py
index ddea8b9098d2..8cab9d8eb17f 100755
--- a/test/functional/llmq-signing.py
+++ b/test/functional/llmq-signing.py
@@ -18,7 +18,7 @@
 
 class LLMQSigningTest(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(6, 5, [], fast_dip3_enforcement=True)
+        self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)
 
     def run_test(self):
 
diff --git a/test/functional/llmq-simplepose.py b/test/functional/llmq-simplepose.py
index e9cb62bf9ef6..576df543cfc0 100755
--- a/test/functional/llmq-simplepose.py
+++ b/test/functional/llmq-simplepose.py
@@ -17,7 +17,7 @@
 
 class LLMQSimplePoSeTest(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(6, 5, [], fast_dip3_enforcement=True)
+        self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)
 
     def run_test(self):
 
diff --git a/test/functional/p2p-instantsend.py b/test/functional/p2p-instantsend.py
index a46e2534d9ae..a1bc0a872a97 100755
--- a/test/functional/p2p-instantsend.py
+++ b/test/functional/p2p-instantsend.py
@@ -16,7 +16,7 @@
 
 class InstantSendTest(DashTestFramework):
     def set_test_params(self):
-        self.set_dash_test_params(9, 5, [], fast_dip3_enforcement=True)
+        self.set_dash_test_params(9, 5, fast_dip3_enforcement=True)
         # set sender,  receiver,  isolated nodes
         self.isolated_idx = 1
         self.receiver_idx = 2
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 5ee1cbbcf7cb..3b19da65c3c5 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -482,24 +482,26 @@ def __init__(self, proTxHash, ownerAddr, votingAddr, pubKeyOperator, keyOperator
 
 
 class DashTestFramework(BitcoinTestFramework):
-    def set_dash_test_params(self, num_nodes, masterodes_count, extra_args, fast_dip3_enforcement=False):
+    def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, fast_dip3_enforcement=False):
         self.mn_count = masterodes_count
         self.num_nodes = num_nodes
         self.mninfo = []
         self.setup_clean_chain = True
         self.is_network_split = False
         # additional args
+        if extra_args is None:
+            extra_args = [[]] * num_nodes
+        assert_equal(len(extra_args), num_nodes)
         self.extra_args = extra_args
-
-        self.extra_args += ["-sporkkey=cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK"]
-
+        self.extra_args[0] += ["-sporkkey=cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK"]
         self.fast_dip3_enforcement = fast_dip3_enforcement
         if fast_dip3_enforcement:
-            self.extra_args += ["-dip3params=30:50"]
+            for i in range(0, num_nodes):
+                self.extra_args[i] += ["-dip3params=30:50"]
 
     def create_simple_node(self):
         idx = len(self.nodes)
-        self.add_nodes(1, extra_args=[self.extra_args])
+        self.add_nodes(1, extra_args=[self.extra_args[idx]])
         self.start_node(idx)
         for i in range(0, idx):
             connect_nodes(self.nodes[i], idx)
@@ -574,7 +576,7 @@ def start_masternodes(self):
         executor = ThreadPoolExecutor(max_workers=20)
 
         def do_start(idx):
-            args = ['-masternodeblsprivkey=%s' % self.mninfo[idx].keyOperator] + self.extra_args
+            args = ['-masternodeblsprivkey=%s' % self.mninfo[idx].keyOperator] + self.extra_args[idx + start_idx]
             self.start_node(idx + start_idx, extra_args=args)
             self.mninfo[idx].nodeIdx = idx + start_idx
             self.mninfo[idx].node = self.nodes[idx + start_idx]
@@ -608,7 +610,7 @@ def do_connect(idx):
 
     def setup_network(self):
         self.log.info("Creating and starting controller node")
-        self.add_nodes(1, extra_args=[self.extra_args])
+        self.add_nodes(1, extra_args=[self.extra_args[0]])
         self.start_node(0)
         required_balance = MASTERNODE_COLLATERAL * self.mn_count + 1
         self.log.info("Generating %d coins" % required_balance)
