Skip to content

Commit

Permalink
Allow config files to specify no bootnodes (PegaSysEng#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored and notlesh committed May 14, 2019
1 parent 505028f commit 427272a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ protected KeyLoader getKeyLoader() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ public void callingWithConfigOptionButInvalidContentTomlFileShouldDisplayHelp()
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());
Expand Down
1 change: 1 addition & 0 deletions pantheon/src/test/resources/no_bootnodes.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bootnodes=[]

0 comments on commit 427272a

Please sign in to comment.