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 900a9912473..49fe22131a2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -3582,6 +3582,9 @@ private String generateConfigurationOverview() { builder.setNetwork(network.normalize()); } + builder.setHasCustomGenesis(genesisFile != null); + builder.setNetworkId(ethNetworkConfig.getNetworkId()); + builder .setDataStorage(dataStorageOptions.normalizeDataStorageFormat()) .setSyncMode(syncMode.normalize()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 546f4f83ce7..45f9b7d3210 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.util.log.FramedLogMessage; import org.hyperledger.besu.util.platform.PlatformDetector; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -29,6 +30,8 @@ /** The Configuration overview builder. */ public class ConfigurationOverviewBuilder { private String network; + private BigInteger networkId; + private boolean hasCustomGenesis; private String dataStorage; private String syncMode; private Integer rpcPort; @@ -48,6 +51,28 @@ public ConfigurationOverviewBuilder setNetwork(final String network) { return this; } + /** + * Sets whether a networkId has been specified + * + * @param networkId the specified networkId + * @return the builder + */ + public ConfigurationOverviewBuilder setNetworkId(final BigInteger networkId) { + this.networkId = networkId; + return this; + } + + /** + * Sets whether a custom genesis has been specified. + * + * @param hasCustomGenesis a boolean representing whether a custom genesis file was specified + * @return the builder + */ + public ConfigurationOverviewBuilder setHasCustomGenesis(final boolean hasCustomGenesis) { + this.hasCustomGenesis = hasCustomGenesis; + return this; + } + /** * Sets data storage. * @@ -135,10 +160,19 @@ public String build() { lines.add(""); lines.add("Configuration:"); - if (network != null) { + // Don't include the default network if a genesis file has been supplied + if (network != null && !hasCustomGenesis) { lines.add("Network: " + network); } + if (hasCustomGenesis) { + lines.add("Network: Custom genesis file specified"); + } + + if (networkId != null) { + lines.add("Network Id: " + networkId); + } + if (dataStorage != null) { lines.add("Data storage: " + dataStorage); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java index 46cac150d80..783b82e419a 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java @@ -16,6 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; @@ -40,6 +41,31 @@ void setNetwork() { assertThat(networkSet).contains("Network: foobar"); } + @Test + void setGenesisFile() { + final String noGenesisSet = builder.build(); + assertThat(noGenesisSet).doesNotContain("Network: Custom genesis file specified"); + + builder.setNetwork("foobar"); + final String networkSet = builder.build(); + assertThat(networkSet).contains("Network: foobar"); + + builder.setHasCustomGenesis(true); + final String genesisSet = builder.build(); + assertThat(genesisSet).contains("Network: Custom genesis file specified"); + assertThat(genesisSet).doesNotContain("Network: foobar"); + } + + @Test + void setNetworkId() { + final String noNetworkIdSet = builder.build(); + assertThat(noNetworkIdSet).doesNotContain("Network Id:"); + + builder.setNetworkId(BigInteger.ONE); + final String networkIdSet = builder.build(); + assertThat(networkIdSet).contains("Network Id: 1"); + } + @Test void setDataStorage() { final String noDataStorageSet = builder.build();