Skip to content

Commit

Permalink
non-existent genesis file: clarify error (hyperledger#2320)
Browse files Browse the repository at this point in the history
* add error message
* added a test for non-existent genesis file

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
  • Loading branch information
macfarla authored May 25, 2021
1 parent 1cb9d28 commit 81d4fac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,8 @@ private GenesisConfigOptions readGenesisConfigOptions() {
final GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig());
genesisConfigOptions = genesisConfigFile.getConfigOptions(genesisConfigOverrides);
} 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;
}
Expand Down
12 changes: 12 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,18 @@ public void genesisAndNetworkMustNotBeUsedTogether() throws Exception {
.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
public void testDnsDiscoveryUrlEthConfig() throws Exception {
final ArgumentCaptor<EthNetworkConfig> networkArg =
Expand Down

0 comments on commit 81d4fac

Please sign in to comment.