|
31 | 31 | DEFAULT_PORT_PLATFORM_HTTP = 22201 |
32 | 32 | # See CDeterministicMNStateDiff::ToJson() in src/evo/dmnstate.h |
33 | 33 | DMNSTATE_DIFF_DUMMY_ADDR = "255.255.255.255" |
| 34 | +# See ProTxVersion in src/evo/providertx.h |
| 35 | +PROTXVER_BASIC = 2 |
| 36 | +PROTXVER_EXTADDR = 3 |
34 | 37 |
|
35 | 38 | class EvoNode: |
36 | 39 | mn: MasternodeInfo |
@@ -187,6 +190,8 @@ def run_test(self): |
187 | 190 | self.log.info("Test input validation for masternode address fields (post-fork)") |
188 | 191 | self.test_validation_common() |
189 | 192 | self.test_validation_extended() |
| 193 | + self.log.info("Test masternode address fields for ProRegTx without addresses") |
| 194 | + self.test_empty_fields() |
190 | 195 | self.log.info("Test output masternode address fields for consistency (post-fork)") |
191 | 196 | self.test_shims() |
192 | 197 |
|
@@ -457,6 +462,48 @@ def test_deprecation(self): |
457 | 462 | assert "service" in protx_diff_rpc['mnList'][0].keys() |
458 | 463 | assert "service" in protx_listdiff_rpc.keys() |
459 | 464 |
|
| 465 | + def test_empty_fields(self): |
| 466 | + def empty_common(grt_dict): |
| 467 | + # Even if '[::]:0' is reported by 'service', 'addresses' should always be blank if we have nothing to report |
| 468 | + assert_equal(len(grt_dict['addresses']), 0) |
| 469 | + # 'service' will never be empty. Legacy addresses stored an empty CService, which evaluates to |
| 470 | + # '[::]:0' when printed in string form. This behavior has been preserved for continuity. |
| 471 | + assert_equal(grt_dict['service'], "[::]:0") |
| 472 | + |
| 473 | + # Validate that our masternode was registered before the fork |
| 474 | + grt_proregtx = self.node_simple.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx'] |
| 475 | + assert_equal(grt_proregtx['version'], PROTXVER_BASIC) |
| 476 | + |
| 477 | + # Test reporting on legacy address (i.e. basic BLS and earlier) nodes |
| 478 | + empty_common(grt_proregtx) |
| 479 | + |
| 480 | + # platform{P2P,HTTP}Port are non-optional fields for legacy addresses and will be populated |
| 481 | + assert_equal(grt_proregtx['platformP2PPort'], DEFAULT_PORT_PLATFORM_P2P) |
| 482 | + assert_equal(grt_proregtx['platformHTTPPort'], DEFAULT_PORT_PLATFORM_HTTP) |
| 483 | + |
| 484 | + # Destroy and re-register node as blank |
| 485 | + self.node_two.destroy_mn(self) |
| 486 | + self.reconnect_nodes() |
| 487 | + self.node_two.register_mn(self, True, "", "", "") |
| 488 | + |
| 489 | + # Validate that masternode uses extended addresses |
| 490 | + grt_proregtx = self.node_simple.getrawtransaction(self.node_two.mn.proTxHash, True)['proRegTx'] |
| 491 | + assert_equal(grt_proregtx['version'], PROTXVER_EXTADDR) |
| 492 | + |
| 493 | + # Test reporting for extended addresses |
| 494 | + empty_common(grt_proregtx) |
| 495 | + |
| 496 | + # Extended addresses store addr:port pairs for platform{P2P,HTTPS}Addrs but ProRegTx allows blank |
| 497 | + # address declarations (for later update with a ProUpServTx), this means that *unlike* legacy |
| 498 | + # addresses, ProRegTxes that opt to omit addresses cannot report platform{P2P,HTTP}Port, which |
| 499 | + # is signified with -1. |
| 500 | + assert_equal(grt_proregtx['platformP2PPort'], -1) |
| 501 | + assert_equal(grt_proregtx['platformHTTPPort'], -1) |
| 502 | + |
| 503 | + # Destroy masternode |
| 504 | + self.node_evo.destroy_mn(self) |
| 505 | + self.reconnect_nodes() |
| 506 | + |
460 | 507 | def test_shims(self): |
461 | 508 | # There are two shims there to help with migrating between legacy and extended addresses, one reads from legacy platform |
462 | 509 | # fields to ensure 'addresses' is adequately populated. The other, reads from netInfo to populate platform{HTTP,P2P}Port. |
|
0 commit comments