Skip to content

Commit

Permalink
Fix RunnerBuilder method names (PegaSysEng#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaxter authored and notlesh committed May 4, 2019
1 parent 3fcf7b0 commit 6cdd98a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public void startNode(final PantheonNode node) {
.pantheonController(pantheonController)
.ethNetworkConfig(ethNetworkConfig)
.discovery(node.isDiscoveryEnabled())
.discoveryHost(node.hostName())
.discoveryPort(0)
.p2pAdvertisedHost(node.hostName())
.p2pListenPort(0)
.maxPeers(25)
.jsonRpcConfiguration(node.jsonRpcConfiguration())
.webSocketConfiguration(node.webSocketConfiguration())
Expand Down
22 changes: 11 additions & 11 deletions pantheon/src/main/java/tech/pegasys/pantheon/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public class RunnerBuilder {
private boolean p2pEnabled = true;
private boolean discovery;
private EthNetworkConfig ethNetworkConfig;
private String discoveryHost;
private int listenPort;
private String p2pAdvertisedHost;
private int p2pListenPort;
private int maxPeers;
private JsonRpcConfiguration jsonRpcConfiguration;
private WebSocketConfiguration webSocketConfiguration;
Expand All @@ -107,8 +107,8 @@ private EnodeURL getSelfEnode() {
BytesValue nodeId = pantheonController.getLocalNodeKeyPair().getPublicKey().getEncodedBytes();
return EnodeURL.builder()
.nodeId(nodeId)
.ipAddress(discoveryHost)
.listeningPort(listenPort)
.ipAddress(p2pAdvertisedHost)
.listeningPort(p2pListenPort)
.build();
}

Expand Down Expand Up @@ -137,13 +137,13 @@ public RunnerBuilder ethNetworkConfig(final EthNetworkConfig ethNetworkConfig) {
return this;
}

public RunnerBuilder discoveryHost(final String discoveryHost) {
this.discoveryHost = discoveryHost;
public RunnerBuilder p2pAdvertisedHost(final String p2pAdvertisedHost) {
this.p2pAdvertisedHost = p2pAdvertisedHost;
return this;
}

public RunnerBuilder discoveryPort(final int listenPort) {
this.listenPort = listenPort;
public RunnerBuilder p2pListenPort(final int p2pListenPort) {
this.p2pListenPort = p2pListenPort;
return this;
}

Expand Down Expand Up @@ -207,8 +207,8 @@ public Runner build() {
}
discoveryConfiguration =
DiscoveryConfiguration.create()
.setBindPort(listenPort)
.setAdvertisedHost(discoveryHost)
.setBindPort(p2pListenPort)
.setAdvertisedHost(p2pAdvertisedHost)
.setBootstrapPeers(bootstrap);
} else {
discoveryConfiguration = DiscoveryConfiguration.create().setActive(false);
Expand All @@ -231,7 +231,7 @@ public Runner build() {

final NetworkingConfiguration networkConfig =
new NetworkingConfiguration()
.setRlpx(RlpxConfiguration.create().setBindPort(listenPort).setMaxPeers(maxPeers))
.setRlpx(RlpxConfiguration.create().setBindPort(p2pListenPort).setMaxPeers(maxPeers))
.setDiscovery(discoveryConfiguration)
.setClientId(PantheonInfo.version())
.setSupportedProtocols(subProtocols);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ void setBootnodes(final List<String> values) {
@Option(
names = {"--p2p-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for P2P peer discovery to listen on (default: ${DEFAULT-VALUE})",
description = "Ip address this node advertises to its peers (default: ${DEFAULT-VALUE})",
arity = "1")
private String p2pHost = autoDiscoverDefaultIP().getHostAddress();

@Option(
names = {"--p2p-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for P2P peer discovery to listen on (default: ${DEFAULT-VALUE})",
description = "Port on which to listen for p2p communication (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer p2pPort = DEFAULT_PORT;

Expand Down Expand Up @@ -942,8 +942,8 @@ private void synchronize(
final boolean peerDiscoveryEnabled,
final EthNetworkConfig ethNetworkConfig,
final int maxPeers,
final String discoveryHost,
final int discoveryPort,
final String p2pAdvertisedHost,
final int p2pListenPort,
final JsonRpcConfiguration jsonRpcConfiguration,
final WebSocketConfiguration webSocketConfiguration,
final MetricsConfiguration metricsConfiguration,
Expand All @@ -962,8 +962,8 @@ private void synchronize(
.p2pEnabled(p2pEnabled)
.discovery(peerDiscoveryEnabled)
.ethNetworkConfig(ethNetworkConfig)
.discoveryHost(discoveryHost)
.discoveryPort(discoveryPort)
.p2pAdvertisedHost(p2pAdvertisedHost)
.p2pListenPort(p2pListenPort)
.maxPeers(maxPeers)
.jsonRpcConfiguration(jsonRpcConfiguration)
.webSocketConfiguration(webSocketConfiguration)
Expand Down
4 changes: 2 additions & 2 deletions pantheon/src/test/java/tech/pegasys/pantheon/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private void syncFromGenesis(final SyncMode mode) throws Exception {
new RunnerBuilder()
.vertx(Vertx.vertx())
.discovery(true)
.discoveryHost(listenHost)
.discoveryPort(0)
.p2pAdvertisedHost(listenHost)
.p2pListenPort(0)
.maxPeers(3)
.metricsSystem(noOpMetricsSystem)
.bannedNodeIds(emptySet())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public void initMocks() throws Exception {
when(mockRunnerBuilder.pantheonController(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.discovery(anyBoolean())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.ethNetworkConfig(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.discoveryHost(anyString())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.discoveryPort(anyInt())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.p2pAdvertisedHost(anyString())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.p2pListenPort(anyInt())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.maxPeers(anyInt())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.p2pEnabled(anyBoolean())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.jsonRpcConfiguration(any())).thenReturn(mockRunnerBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public void callingPantheonCommandWithoutOptionsMustSyncWithDefaultValues() thro
EthNetworkConfig.jsonConfig(MAINNET),
EthNetworkConfig.MAINNET_NETWORK_ID,
MAINNET_BOOTSTRAP_NODES));
verify(mockRunnerBuilder).discoveryHost(eq("127.0.0.1"));
verify(mockRunnerBuilder).discoveryPort(eq(30303));
verify(mockRunnerBuilder).p2pAdvertisedHost(eq("127.0.0.1"));
verify(mockRunnerBuilder).p2pListenPort(eq(30303));
verify(mockRunnerBuilder).maxPeers(eq(25));
verify(mockRunnerBuilder).jsonRpcConfiguration(eq(defaultJsonRpcConfiguration));
verify(mockRunnerBuilder).webSocketConfiguration(eq(defaultWebSocketConfiguration));
Expand Down Expand Up @@ -280,8 +280,8 @@ public void overrideDefaultValuesIfKeyIsPresentInConfigFile() throws IOException

verify(mockRunnerBuilder).discovery(eq(false));
verify(mockRunnerBuilder).ethNetworkConfig(ethNetworkConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).discoveryHost(eq("1.2.3.4"));
verify(mockRunnerBuilder).discoveryPort(eq(1234));
verify(mockRunnerBuilder).p2pAdvertisedHost(eq("1.2.3.4"));
verify(mockRunnerBuilder).p2pListenPort(eq(1234));
verify(mockRunnerBuilder).maxPeers(eq(42));
verify(mockRunnerBuilder).jsonRpcConfiguration(eq(jsonRpcConfiguration));
verify(mockRunnerBuilder).webSocketConfiguration(eq(webSocketConfiguration));
Expand Down Expand Up @@ -597,8 +597,8 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() throws IOExce
EthNetworkConfig.jsonConfig(MAINNET),
EthNetworkConfig.MAINNET_NETWORK_ID,
MAINNET_BOOTSTRAP_NODES));
verify(mockRunnerBuilder).discoveryHost(eq("127.0.0.1"));
verify(mockRunnerBuilder).discoveryPort(eq(30303));
verify(mockRunnerBuilder).p2pAdvertisedHost(eq("127.0.0.1"));
verify(mockRunnerBuilder).p2pListenPort(eq(30303));
verify(mockRunnerBuilder).maxPeers(eq(25));
verify(mockRunnerBuilder).jsonRpcConfiguration(eq(jsonRpcConfiguration));
verify(mockRunnerBuilder).webSocketConfiguration(eq(webSocketConfiguration));
Expand Down Expand Up @@ -981,8 +981,8 @@ public void p2pHostAndPortOptionMustBeUsed() {
final int port = 1234;
parseCommand("--p2p-host", host, "--p2p-port", String.valueOf(port));

verify(mockRunnerBuilder).discoveryHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).discoveryPort(intArgumentCaptor.capture());
verify(mockRunnerBuilder).p2pAdvertisedHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).p2pListenPort(intArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(stringArgumentCaptor.getValue()).isEqualTo(host);
Expand All @@ -998,7 +998,7 @@ public void p2pHostMayBeLocalhost() {
final String host = "localhost";
parseCommand("--p2p-host", host);

verify(mockRunnerBuilder).discoveryHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).p2pAdvertisedHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(stringArgumentCaptor.getValue()).isEqualTo(host);
Expand All @@ -1013,7 +1013,7 @@ public void p2pHostMayBeIPv6() {
final String host = "2600:DB8::8545";
parseCommand("--p2p-host", host);

verify(mockRunnerBuilder).discoveryHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).p2pAdvertisedHost(stringArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(stringArgumentCaptor.getValue()).isEqualTo(host);
Expand Down

0 comments on commit 6cdd98a

Please sign in to comment.