From adf19afb1ac7cbd4593d0c6f05ed355d63bd65e4 Mon Sep 17 00:00:00 2001 From: Suyash Nayan <89125422+7suyash7@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:36:24 +0530 Subject: [PATCH] Correct default `--help` values (#7454) * Fix #7367: Correct default value display for --rpc-max-trace-filter-range along with a test * Fix #7369: Show default value for --genesis-state-hash-cache-enabled Signed-off-by: 7suyash7 --- .../java/org/hyperledger/besu/cli/BesuCommand.java | 3 ++- .../cli/options/stable/ApiConfigurationOptions.java | 2 +- .../org/hyperledger/besu/cli/BesuCommandTest.java | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 72fbb48ec96..67a360a882f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -375,7 +375,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { @Option( names = {"--genesis-state-hash-cache-enabled"}, - description = "Use genesis state hash from data on startup if specified") + description = + "Use genesis state hash from data on startup if specified (default: ${DEFAULT-VALUE})") private final Boolean genesisStateHashCacheEnabled = false; @Option( diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java index d9882382769..fbed68de0cd 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java @@ -85,7 +85,7 @@ public ApiConfigurationOptions() {} @CommandLine.Option( names = {"--rpc-max-trace-filter-range"}, description = - "Specifies the maximum number of blocks for the trace_filter method. Must be >=0. 0 specifies no limit (default: $DEFAULT-VALUE)") + "Specifies the maximum number of blocks for the trace_filter method. Must be >=0. 0 specifies no limit (default: ${DEFAULT-VALUE})") private final Long maxTraceFilterRange = 1000L; /** diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index d0c42f67188..23ba593a384 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -2503,4 +2503,16 @@ public void genesisStateHashCacheEnabledShouldWork() throws IOException { assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } + + @Test + void helpOutputShouldDisplayCorrectDefaultValues() { + parseCommand("--help"); + + final String commandOutputString = commandOutput.toString(UTF_8); + final String errorOutputString = commandErrorOutput.toString(UTF_8); + + assertThat(commandOutputString).doesNotContain("$DEFAULT-VALUE"); + + assertThat(errorOutputString).isEmpty(); + } }