@@ -1326,6 +1326,42 @@ def update_registrar(self, node: TestNode, pubKeyOperator: Optional[str] = None,
13261326
13271327 return node .protx (command , * args )
13281328
1329+ def update_service (self , node : TestNode , ipAndPort : Optional [str ] = None , platform_node_id : Optional [str ] = None , platform_p2p_port : Optional [int ] = None ,
1330+ platform_http_port : Optional [int ] = None , address_operator : Optional [str ] = None , fundsAddr : Optional [str ] = None ) -> str :
1331+ # Update commands should be run from the appropriate MasternodeInfo instance, we do not allow overriding some values for this reason
1332+ if self .proTxHash is None :
1333+ raise AssertionError ("proTxHash not set, did you call set_params()" )
1334+ if self .keyOperator is None :
1335+ raise AssertionError ("keyOperator not set, did you call generate_addresses()" )
1336+
1337+ # EvoNode-specific fields are ignored for regular masternodes
1338+ if self .evo :
1339+ if platform_node_id is None :
1340+ raise AssertionError ("EvoNode but platform_node_id is missing, must be specified!" )
1341+ if platform_p2p_port is None :
1342+ raise AssertionError ("EvoNode but platform_p2p_port is missing, must be specified!" )
1343+ if platform_http_port is None :
1344+ raise AssertionError ("EvoNode but platform_http_port is missing, must be specified!" )
1345+
1346+ # Common arguments shared between regular masternodes and EvoNodes
1347+ args = [
1348+ self .proTxHash ,
1349+ ipAndPort or f'127.0.0.1:{ self .nodePort } ' ,
1350+ self .keyOperator ,
1351+ ]
1352+ address_funds = fundsAddr or self .fundsAddr
1353+ address_operator = address_operator or ""
1354+
1355+ # Construct final command and arguments
1356+ if self .evo :
1357+ command = "update_service_evo"
1358+ args = args + [platform_node_id , platform_p2p_port , platform_http_port , address_operator , address_funds ] # type: ignore
1359+ else :
1360+ command = "update_service"
1361+ args = args + [address_operator , address_funds ] # type: ignore
1362+
1363+ return node .protx (command , * args )
1364+
13291365class DashTestFramework (BitcoinTestFramework ):
13301366 def set_test_params (self ):
13311367 """Tests must this method to change default values for number of nodes, topology, etc"""
@@ -1527,16 +1563,16 @@ def dynamically_evo_update_service(self, evo_info: MasternodeInfo, rnd=None, sho
15271563 # For the sake of the test, generate random nodeid, p2p and http platform values
15281564 r = rnd if rnd is not None else random .randint (21000 , 65000 )
15291565 platform_node_id = hash160 (b'%d' % r ).hex ()
1530- platform_p2p_port = '%d' % ( r + 1 )
1531- platform_http_port = '%d' % ( r + 2 )
1566+ platform_p2p_port = r + 1
1567+ platform_http_port = r + 2
15321568
15331569 fund_txid = self .nodes [0 ].sendtoaddress (funds_address , 1 )
15341570 self .bump_mocktime (10 * 60 + 1 ) # to make tx safe to include in block
15351571 evo_info .bury_tx (self , genIdx = 0 , txid = fund_txid , depth = 1 )
15361572
15371573 protx_success = False
15381574 try :
1539- protx_result = self .nodes [0 ]. protx ( 'update_service_evo' , evo_info . proTxHash , f'127.0.0.1:{ evo_info .nodePort } ' , evo_info . keyOperator , platform_node_id , platform_p2p_port , platform_http_port , operator_reward_address , funds_address )
1575+ protx_result = evo_info . update_service ( self .nodes [0 ], f'127.0.0.1:{ evo_info .nodePort } ' , platform_node_id , platform_p2p_port , platform_http_port , operator_reward_address , funds_address )
15401576 self .bump_mocktime (10 * 60 + 1 ) # to make tx safe to include in block
15411577 evo_info .bury_tx (self , genIdx = 0 , txid = protx_result , depth = 1 )
15421578 self .log .info ("Updated EvoNode %s: platformNodeID=%s, platformP2PPort=%s, platformHTTPPort=%s" % (evo_info .proTxHash , platform_node_id , platform_p2p_port , platform_http_port ))
@@ -1583,12 +1619,13 @@ def prepare_masternode(self, idx):
15831619 else :
15841620 proTxHash = self .nodes [0 ].sendrawtransaction (protx_result )
15851621
1622+ mn .set_params (proTxHash = proTxHash , operator_reward = operatorReward , collateral_txid = txid , collateral_vout = collateral_vout , nodePort = port )
1623+
15861624 if operatorReward > 0 :
15871625 self .generate (self .nodes [0 ], 1 , sync_fun = self .no_op )
15881626 operatorPayoutAddress = self .nodes [0 ].getnewaddress ()
1589- self .nodes [0 ]. protx ( 'update_service' , proTxHash , ipAndPort , mn . keyOperator , operatorPayoutAddress , mn . fundsAddr )
1627+ mn . update_service ( self .nodes [0 ], ipAndPort = ipAndPort , address_operator = operatorPayoutAddress )
15901628
1591- mn .set_params (proTxHash = proTxHash , operator_reward = operatorReward , collateral_txid = txid , collateral_vout = collateral_vout , nodePort = port )
15921629 self .mninfo .append (mn )
15931630 self .log .info ("Prepared MN %d: collateral_txid=%s, collateral_vout=%d, protxHash=%s" % (idx , txid , collateral_vout , proTxHash ))
15941631
0 commit comments