Allow config files to specify no bootnodes (#1438)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent c13e8d5a92
commit 2994939d42
  1. 5
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  2. 16
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
  3. 1
      pantheon/src/test/resources/no_bootnodes.toml

@ -188,7 +188,10 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
void setBootnodes(final List<String> values) {
try {
bootNodes =
values.stream().map((s) -> EnodeURL.fromString(s).toURI()).collect(Collectors.toList());
values.stream()
.filter(value -> !value.isEmpty())
.map(value -> EnodeURL.fromString(value).toURI())
.collect(Collectors.toList());
} catch (final IllegalArgumentException e) {
throw new ParameterException(commandLine, e.getMessage());
}

@ -234,6 +234,22 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString()).isEmpty();
}
@Test
public void callingWithNoBootnodesConfig() throws Exception {
assumeTrue(isFullInstantiation());
final URL configFile = this.getClass().getResource("/no_bootnodes.toml");
final Path toml = createTempFile("toml", Resources.toString(configFile, UTF_8));
parseCommand("--config-file", toml.toAbsolutePath().toString());
verify(mockRunnerBuilder).ethNetworkConfig(ethNetworkConfigArgumentCaptor.capture());
assertThat(ethNetworkConfigArgumentCaptor.getValue().getBootNodes()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
}
@Test
public void callingWithConfigOptionButInvalidValueTomlFileShouldDisplayHelp() throws Exception {
assumeTrue(isFullInstantiation());

Loading…
Cancel
Save