Skip to content

Commit 4e31101

Browse files
committed
fixup: for mnoperation.py with setupmasternode config
1 parent 12dac06 commit 4e31101

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

divi/qa/rpc-tests/masternode.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MnConfigLine (object):
1414

1515
def __init__ (self, line):
1616
parts = line.split (" ")
17-
assert len (parts) in [5, 6]
17+
assert_equal(len(parts), 5)
1818

1919
self.line = line
2020

@@ -24,21 +24,6 @@ def __init__ (self, line):
2424
self.txid = parts[3]
2525
self.vout = int (parts[4])
2626

27-
if len (parts) >= 6:
28-
self.rewardAddr = parts[5]
29-
else:
30-
self.rewardAddr = None
31-
32-
def getLine (self):
33-
"""Returns the config line as string, to put into masternode.conf."""
34-
35-
res = "%s %s %s %s %d" % (self.alias, self.ip, self.privkey,
36-
self.txid, self.vout)
37-
if self.rewardAddr is not None:
38-
res += " %s" % self.rewardAddr
39-
40-
return res
41-
4227

4328
def fund_masternode (node, alias, tier, txid, ip):
4429
"""Calls fundmasternode with the given data and returns the
@@ -60,7 +45,7 @@ def __init__(self, setup_data,address=None):
6045
if address is not None:
6146
self.address = address
6247

63-
def setup_masternode(mempoolSync,controlNode, hostNode,alias,tier,hostIP, utxo = None):
48+
def setup_masternode(mempoolSync,controlNode, hostNode,alias,tier,hostIP, utxo = None, rewardAddr=""):
6449
"""Calls fundmasternode with the given data and returns the
6550
MnConfigLine instance."""
6651
txdata = None
@@ -77,7 +62,7 @@ def setup_masternode(mempoolSync,controlNode, hostNode,alias,tier,hostIP, utxo =
7762
pubkey = controlNode.validateaddress(address)["pubkey"]
7863
if sync_required:
7964
mempoolSync()
80-
data = hostNode.setupmasternode(alias,txdata["txhash"],str(txdata["vout"]), pubkey, hostIP)
65+
data = hostNode.setupmasternode(alias,txdata["txhash"],str(txdata["vout"]), pubkey, hostIP, rewardAddr)
8166
return MnSetupData (data,address)
8267

8368
class MnTestFramework(BitcoinTestFramework):
@@ -101,12 +86,12 @@ def for_each_masternode(self, masternode_function):
10186

10287
return result
10388

104-
def setup_masternode(self,controlNodeIndex, hostNodeIndex,alias,tier,utxo=None):
89+
def setup_masternode(self,controlNodeIndex, hostNodeIndex,alias,tier,utxo=None, rewardAddr=""):
10590
def mempoolSync():
10691
sync_mempools (self.nodes)
10792
controlNode = self.nodes[controlNodeIndex]
10893
hostNode = self.nodes[hostNodeIndex]
109-
self.setup[hostNodeIndex] = setup_masternode(mempoolSync,controlNode,hostNode,alias, tier,"localhost:%d" % p2p_port (hostNodeIndex),utxo=utxo)
94+
self.setup[hostNodeIndex] = setup_masternode(mempoolSync,controlNode,hostNode,alias, tier,"localhost:%d" % p2p_port (hostNodeIndex),utxo=utxo, rewardAddr=rewardAddr)
11095
self.mn_control_node_indices[alias] = controlNodeIndex
11196
self.mn_host_node_indices[alias] = hostNodeIndex
11297

@@ -201,7 +186,7 @@ def start_masternode(nodeIndex):
201186
args = self.args_for(nodeIndex)
202187
conf = self.setup[nodeIndex].cfg
203188
args.append ("-masternode=%s" % conf.alias)
204-
self.nodes[nodeIndex] = start_node (nodeIndex, self.options.tmpdir, extra_args=args, mn_config_lines=[conf.getLine()])
189+
self.nodes[nodeIndex] = start_node (nodeIndex, self.options.tmpdir, extra_args=args, mn_config_lines=[conf.line])
205190
if updateMockTime:
206191
set_node_times([self.nodes[nodeIndex]],self.time)
207192
self.for_each_masternode(start_masternode)

divi/qa/rpc-tests/mnoperation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def fund_masternodes (self):
9090
self.mine_blocks (25)
9191
assert_equal (self.nodes[0].getbalance (), 6250)
9292

93+
self.rewardAddr = self.nodes[0].getnewaddress ("reward2")
9394
self.setup_masternode(0,1,"mn1","copper")
94-
self.setup_masternode(0,2,"mn2","silver")
95-
self.setup[1].cfg.rewardAddr = self.nodes[0].getnewaddress ("reward2")
95+
self.setup_masternode(0,2,"mn2","silver",rewardAddr=self.rewardAddr)
9696
self.mine_blocks (15)
9797
set_node_times (self.nodes, self.time)
9898
self.mine_blocks (1)
@@ -182,7 +182,7 @@ def payments_both_active (self):
182182
winners = self.verify_number_of_votes_exist_and_tally_winners(startHeight,endHeight, 2)
183183

184184
addr1 = self.nodes[1].getmasternodestatus ()["addr"]
185-
addr2 = self.setup[1].cfg.rewardAddr
185+
addr2 = self.rewardAddr
186186
assert_equal (len (winners), 2)
187187
assert_greater_than (winners[addr1], 0)
188188
assert_greater_than (winners[addr2], 0)

0 commit comments

Comments
 (0)