From 17ab4daa996e9ec70fac35a001725618a04508a2 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 9 Jan 2024 16:04:59 +1000 Subject: [PATCH] full sync - don't fail startup if sync-min-peers specified Signed-off-by: Sally MacFarlane --- .../java/org/hyperledger/besu/cli/BesuCommand.java | 10 +++++----- .../java/org/hyperledger/besu/cli/BesuCommandTest.java | 3 +-- 2 files changed, 6 insertions(+), 7 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 e69bcd44872..9842d52f875 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -23,6 +23,7 @@ import static org.hyperledger.besu.cli.config.NetworkName.MAINNET; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPRECATION_WARNING_MSG; +import static org.hyperledger.besu.cli.util.CommandLineUtils.isOptionSet; import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH; import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT; @@ -2027,11 +2028,10 @@ private void issueOptionWarnings() { "--p2p-port", "--remote-connections-max-percentage")); - CommandLineUtils.failIfOptionDoesntMeetRequirement( - commandLine, - "--fast-sync-min-peers can't be used with FULL sync-mode", - !SyncMode.isFullSync(getDefaultSyncModeIfNotSet()), - singletonList("--fast-sync-min-peers")); + if (SyncMode.isFullSync(getDefaultSyncModeIfNotSet()) + && isOptionSet(commandLine, "--sync-min-peers")) { + logger.warn("--sync-min-peers is ignored in FULL sync-mode"); + } CommandLineUtils.failIfOptionDoesntMeetRequirement( commandLine, 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 baa75477eab..ba0e5b2754a 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -5066,8 +5066,7 @@ public void logsSuggestInstallingJemallocWhenEnvVarNotPresent() { @Test public void logWarnIfFastSyncMinPeersUsedWithFullSync() { parseCommand("--sync-mode", "FULL", "--fast-sync-min-peers", "1"); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains("--fast-sync-min-peers can't be used with FULL sync-mode"); + verify(mockLogger).warn("--sync-min-peers is ignored in FULL sync-mode"); } @Test