-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-2386] Report the correct tcp port in PING packets when it differs from the UDP port #1019
Conversation
@@ -145,7 +145,7 @@ public MockPeerDiscoveryAgent startDiscoveryAgent( | |||
|
|||
public MockPeerDiscoveryAgent startDiscoveryAgent(final AgentBuilder agentBuilder) { | |||
final MockPeerDiscoveryAgent agent = createDiscoveryAgent(agentBuilder); | |||
agent.start(); | |||
agent.start(65500).join(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use PeerDiscoveryTestHelper.nextAvailablePort
here. Or you could try grabbing the discovery port from the agent's config and reusing that for the tcp port. Would be nice if we don't have to start scattering random numbers throughout the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to clean up the rest of the magic numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look. They are just arbitrary numbers since we don't assert on them and don't open a port for them anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pulled them out as constants - one of the tests already had a constant it had used for this previously.
PR description
When Pantheon is started with
--p2p-port=0
an available port is selected for the UDP peer discovery and TCP peer connections but there is no guarantee this port will be the same. Previously Pantheon would assume the UDP and TCP ports were the same so send the UDP port in place of the TCP port in PING messages, making it impossible for other peers to connect to it as they would use the wrong port.