non-existent genesis file: clarify error (#2320)

* add error message
* added a test for non-existent genesis file

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/2333/head
Sally MacFarlane 4 years ago committed by GitHub
parent 1cb9d2826c
commit 81d4fac8c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 12
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java

@ -1488,7 +1488,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig()); final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig());
genesisConfigOptions = genesisConfigFile.getConfigOptions(genesisConfigOverrides); genesisConfigOptions = genesisConfigFile.getConfigOptions(genesisConfigOverrides);
} catch (final Exception e) { } catch (final Exception e) {
throw new IllegalStateException("Unable to read genesis file for GoQuorum options", e); throw new ParameterException(
this.commandLine, "Unable to load genesis file. " + e.getCause());
} }
return genesisConfigOptions; return genesisConfigOptions;
} }

@ -994,6 +994,18 @@ public class BesuCommandTest extends CommandTestAbstract {
.startsWith("--network option and --genesis-file option can't be used at the same time."); .startsWith("--network option and --genesis-file option can't be used at the same time.");
} }
@Test
public void nonExistentGenesisGivesError() throws Exception {
final String nonExistentGenesis = "non-existent-genesis.json";
parseCommand("--genesis-file", nonExistentGenesis);
Mockito.verifyZeroInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).startsWith("Unable to load genesis file");
assertThat(commandErrorOutput.toString()).contains(nonExistentGenesis);
}
@Test @Test
public void testDnsDiscoveryUrlEthConfig() throws Exception { public void testDnsDiscoveryUrlEthConfig() throws Exception {
final ArgumentCaptor<EthNetworkConfig> networkArg = final ArgumentCaptor<EthNetworkConfig> networkArg =

Loading…
Cancel
Save