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 c944907caf7..4c66897c595 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1474,7 +1474,6 @@ private void registerConverters() { commandLine.registerConverter(Address.class, Address::fromHexStringStrict); commandLine.registerConverter(Bytes.class, Bytes::fromHexString); commandLine.registerConverter(Level.class, Level::valueOf); - commandLine.registerConverter(SyncMode.class, SyncMode::fromString); commandLine.registerConverter(MetricsProtocol.class, MetricsProtocol::fromString); commandLine.registerConverter(UInt256.class, (arg) -> UInt256.valueOf(new BigInteger(arg))); commandLine.registerConverter(Wei.class, (arg) -> Wei.of(Long.parseUnsignedLong(arg))); 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 c93ea66b429..e1cbe33e509 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -1620,6 +1620,17 @@ public void syncMode_full() { assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); } + @Test + public void syncMode_invalid() { + parseCommand("--sync-mode", "bogus"); + Mockito.verifyNoInteractions(mockRunnerBuilder); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)) + .contains( + "Invalid value for option '--sync-mode': expected one of [FULL, FAST, X_SNAP, X_CHECKPOINT] (case-insensitive) but was 'bogus'"); + } + @Test public void syncMode_full_by_default_for_dev() { parseCommand("--network", "dev"); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncMode.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncMode.java index 64f36cf7a78..c3b8d336c44 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncMode.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncMode.java @@ -26,15 +26,6 @@ public enum SyncMode { // Perform snapsync but starting from a checkpoint instead of starting from genesis X_CHECKPOINT; - public static SyncMode fromString(final String str) { - for (final SyncMode mode : SyncMode.values()) { - if (mode.name().equalsIgnoreCase(str)) { - return mode; - } - } - return null; - } - public static boolean isFullSync(final SyncMode syncMode) { return !EnumSet.of(SyncMode.FAST, SyncMode.X_SNAP, SyncMode.X_CHECKPOINT).contains(syncMode); }