2626# See CRegTestParams in src/chainparams.cpp
2727DEFAULT_PORT_PLATFORM_P2P = 22200
2828DEFAULT_PORT_PLATFORM_HTTP = 22201
29+ # See CDeterministicMNStateDiff::ToJson() in src/evo/dmnstate.h
30+ DMNSTATE_DIFF_DUMMY_ADDR = "255.255.255.255"
2931
3032class Node :
3133 mn : MasternodeInfo
@@ -240,14 +242,19 @@ def test_deprecation(self):
240242 self .connect_nodes (self .node_evo .mn .nodeIdx , self .node_simple .index ) # Needed as restarts don't reconnect nodes
241243
242244 # CProUpServTx::ToJson() <- TxToUniv() <- TxToJSON() <- getrawtransaction
243- proupservtx_hash = self .node_evo .update_mn (self , f"127.0.0.1:{ self .node_evo .mn .nodePort + 1 } " , DEFAULT_PORT_PLATFORM_P2P , DEFAULT_PORT_PLATFORM_HTTP )
245+ # We need to update *thrice*, the first time to incorrect values and the second time, (back) to correct values and the third time, only
246+ # updating Platform fields to trigger the conditions needed to report the dummy address
247+ proupservtx_hash = self .node_evo .update_mn (self , f"127.0.0.1:{ self .node_evo .mn .nodePort + 10 } " , DEFAULT_PORT_PLATFORM_P2P + 10 , DEFAULT_PORT_PLATFORM_HTTP + 10 )
244248 proupservtx_rpc = self .node_evo .node .getrawtransaction (proupservtx_hash , True )
245249
246- # We need to update *twice*, the first time to incorrect values and the second time, back to correct values.
247- # This is to make sure that the fields we need to check against are reflected in the diff.
250+ # Restore back to defaults
248251 proupservtx_hash = self .node_evo .update_mn (self , f"127.0.0.1:{ self .node_evo .mn .nodePort } " , DEFAULT_PORT_PLATFORM_P2P , DEFAULT_PORT_PLATFORM_HTTP )
249252 proupservtx_rpc = self .node_evo .node .getrawtransaction (proupservtx_hash , True )
250253
254+ # Revert back to incorrect values but only for Platform fields
255+ proupservtx_hash_pl = self .node_evo .update_mn (self , f"127.0.0.1:{ self .node_evo .mn .nodePort } " , DEFAULT_PORT_PLATFORM_P2P + 10 , DEFAULT_PORT_PLATFORM_HTTP + 10 )
256+ proupservtx_rpc_pl = self .node_evo .node .getrawtransaction (proupservtx_hash_pl , True )
257+
251258 # CSimplifiedMNListEntry::ToJson() <- CSimplifiedMNListDiff::mnList <- CSimplifiedMNListDiff::ToJson() <- protx_diff
252259 masternode_active_height : int = masternode_status ['dmnState' ]['registeredHeight' ]
253260 protx_diff_rpc = self .node_evo .node .protx ('diff' , masternode_active_height - 1 , masternode_active_height )
@@ -256,6 +263,10 @@ def test_deprecation(self):
256263 proupservtx_height = proupservtx_rpc ['height' ]
257264 protx_listdiff_rpc = self .node_evo .node .protx ('listdiff' , proupservtx_height - 1 , proupservtx_height )
258265
266+ # If the core P2P address wasn't updated and the platform fields were, CDeterministicMNStateDiff will return a dummy address
267+ proupservtx_height_pl = proupservtx_rpc_pl ['height' ]
268+ protx_listdiff_rpc_pl = self .node_evo .node .protx ('listdiff' , proupservtx_height_pl - 1 , proupservtx_height_pl )
269+
259270 self .log .info ("Test RPCs return an 'addresses' field" )
260271 assert "addresses" in proregtx_rpc ['proRegTx' ].keys ()
261272 assert "addresses" in masternode_status ['dmnState' ].keys ()
@@ -269,8 +280,12 @@ def test_deprecation(self):
269280 self .check_netinfo_fields (proupservtx_rpc ['proUpServTx' ]['addresses' ], self .node_evo .mn .nodePort , DEFAULT_PORT_PLATFORM_HTTP , DEFAULT_PORT_PLATFORM_P2P )
270281 # CSimplifiedMNListEntry doesn't store platform P2P network information before extended addresses
271282 self .check_netinfo_fields (protx_diff_rpc ['mnList' ][0 ]['addresses' ], self .node_evo .mn .nodePort , DEFAULT_PORT_PLATFORM_HTTP , None )
272- # TODO: Fix reporting for CDeterministicMNStateDiff
273- self .check_netinfo_fields (protx_listdiff_rpc ['updatedMNs' ][0 ][proregtx_hash ]['addresses' ], self .node_evo .mn .nodePort , None , None )
283+ # CDeterministicMNStateDiff will fill in the correct address if the core P2P address was updated *alongside* platform fields
284+ self .check_netinfo_fields (protx_listdiff_rpc ['updatedMNs' ][0 ][proregtx_hash ]['addresses' ], self .node_evo .mn .nodePort , DEFAULT_PORT_PLATFORM_HTTP , DEFAULT_PORT_PLATFORM_P2P )
285+ # CDeterministicMNStateDiff will use a dummy address if the core P2P address wasn't updated but Platform fields were to ensure changes are reported
286+ assert "core_p2p" not in protx_listdiff_rpc_pl ['updatedMNs' ][0 ][proregtx_hash ]['addresses' ].keys ()
287+ assert_equal (protx_listdiff_rpc_pl ['updatedMNs' ][0 ][proregtx_hash ]['addresses' ]['platform_https' ][0 ], f"{ DMNSTATE_DIFF_DUMMY_ADDR } :{ DEFAULT_PORT_PLATFORM_HTTP + 10 } " )
288+ assert_equal (protx_listdiff_rpc_pl ['updatedMNs' ][0 ][proregtx_hash ]['addresses' ]['platform_p2p' ][0 ], f"{ DMNSTATE_DIFF_DUMMY_ADDR } :{ DEFAULT_PORT_PLATFORM_P2P + 10 } " )
274289
275290 self .log .info ("Test RPCs by default no longer return a 'service' field" )
276291 assert "service" not in proregtx_rpc ['proRegTx' ].keys ()
0 commit comments