Skip to content

Commit

Permalink
add correct default to rpcHost (#7725)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Sally MacFarlane <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
  • Loading branch information
macfarla and siladu authored Oct 4, 2024
1 parent 81f9fc9 commit 21e95a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.cli.options.stable;

import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_PORT;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_PRETTY_JSON_ENABLED;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
Expand Down Expand Up @@ -65,7 +66,7 @@ public class JsonRpcHttpOptions {
paramLabel = DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP,
description = "Host for JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String rpcHttpHost;
private String rpcHttpHost = DEFAULT_JSON_RPC_HOST;

@CommandLine.Option(
names = {"--rpc-http-port"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,12 @@ public void p2pHostAndPortOptionsAreRespected() {

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();

// rpc host should remain default ie 127.0.0.1
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();

assertThat(jsonRpcConfigArgumentCaptor.getValue().getHost()).isEqualTo("127.0.0.1");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.google.common.base.MoreObjects;

public class JsonRpcConfiguration {
private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1";
public static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1";
public static final int DEFAULT_JSON_RPC_PORT = 8545;
public static final int DEFAULT_ENGINE_JSON_RPC_PORT = 8551;
public static final int DEFAULT_MAX_ACTIVE_CONNECTIONS = 80;
Expand Down

0 comments on commit 21e95a9

Please sign in to comment.