Skip to content

Commit

Permalink
Rename CLI flag for better ordering of options (PegaSysEng#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaxter authored Jul 17, 2019
1 parent dff81a5 commit c0872a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void setBootnodes(final List<String> values) {
private final Boolean isLimitRemoteWireConnectionsEnabled = true;

@Option(
names = {"--max-remote-connections-percentage"},
names = {"--remote-connections-max-percentage"},
paramLabel = MANDATORY_DOUBLE_FORMAT_HELP,
description =
"The maximum percentage of P2P connections that can be initiated remotely. Must be between 0 and 100 inclusive. (default: ${DEFAULT-VALUE})",
Expand Down Expand Up @@ -796,7 +796,7 @@ private PantheonCommand checkOptions() {
"--max-peers",
"--banned-node-id",
"--banned-node-ids",
"--max-remote-connections-percentage"));
"--remote-connections-max-percentage"));
// Check that mining options are able to work or send an error
checkOptionDependencies(
logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ public void p2pOptionsRequiresServiceToBeEnabled() {
"false",
"--max-peers",
"42",
"--max-remote-connections-percentage",
"--remote-connections-max-percentage",
"50",
"--banned-node-id",
String.join(",", nodes),
Expand All @@ -1036,7 +1036,7 @@ public void p2pOptionsRequiresServiceToBeEnabled() {
"--bootnodes",
"--max-peers",
"--banned-node-ids",
"--max-remote-connections-percentage");
"--remote-connections-max-percentage");

assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
Expand Down Expand Up @@ -1247,7 +1247,7 @@ public void remoteConnectionsPercentageOptionMustBeUsed() {
final int remoteConnectionsPercentage = 12;
parseCommand(
"--remote-connections-limit-enabled",
"--max-remote-connections-percentage",
"--remote-connections-max-percentage",
String.valueOf(remoteConnectionsPercentage));

verify(mockRunnerBuilder).fractionRemoteConnectionsAllowed(floatCaptor.capture());
Expand All @@ -1265,25 +1265,25 @@ public void remoteConnectionsPercentageOptionMustBeUsed() {
public void remoteConnectionsPercentageWithInvalidFormatMustFail() {

parseCommand(
"--remote-connections-limit-enabled", "--max-remote-connections-percentage", "invalid");
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "invalid");
verifyZeroInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString())
.contains(
"Invalid value for option '--max-remote-connections-percentage'",
"Invalid value for option '--remote-connections-max-percentage'",
"should be a number between 0 and 100 inclusive");
}

@Test
public void remoteConnectionsPercentageWithOutOfRangeMustFail() {

parseCommand(
"--remote-connections-limit-enabled", "--max-remote-connections-percentage", "150");
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "150");
verifyZeroInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString())
.contains(
"Invalid value for option '--max-remote-connections-percentage'",
"Invalid value for option '--remote-connections-max-percentage'",
"should be a number between 0 and 100 inclusive");
}

Expand Down
2 changes: 1 addition & 1 deletion pantheon/src/test/resources/everything_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ p2p-host="1.2.3.4"
p2p-port=1234
max-peers=42
remote-connections-limit-enabled=true
max-remote-connections-percentage=60
remote-connections-max-percentage=60
host-whitelist=["all"]

# chain
Expand Down

0 comments on commit c0872a3

Please sign in to comment.