From 2dcd537148f05e33461658d6ab54ced200578660 Mon Sep 17 00:00:00 2001 From: mark-terry <36909937+mark-terry@users.noreply.github.com> Date: Mon, 14 Jan 2019 16:11:59 +1000 Subject: [PATCH] [NC-2105] Updated --bootnodes CLI option to take zero arguments, to configure Pantheon to run in 'bootnode' mode. (#548) Signed-off-by: Adrian Sutton --- .../pegasys/pantheon/cli/PantheonCommand.java | 2 +- .../pantheon/cli/PantheonCommandTest.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index 73dd539982..bd91c7a141 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -179,7 +179,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { "Comma separated enode URLs for P2P discovery bootstrap. " + "Default is a predefined list.", split = ",", - arity = "1..*", + arity = "0..*", converter = EnodeToURIPropertyConverter.class ) private final Collection bootstrapNodes = null; diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index d66b95f154..7247b693fc 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -489,6 +489,7 @@ public class PantheonCommandTest extends CommandTestAbstract { assertThat(commandErrorOutput.toString()).isEmpty(); } + @Ignore("NC-2015 - Temporarily enabling zero-arg --bootnodes to permit 'bootnode' configuration") @Test public void callingWithBootnodesOptionButNoValueMustDisplayErrorAndUsage() { parseCommand("--bootnodes"); @@ -498,6 +499,21 @@ public class PantheonCommandTest extends CommandTestAbstract { assertThat(commandErrorOutput.toString()).startsWith(expectedErrorOutputStart); } + @Test + public void callingWithBootnodesOptionButNoValueMustPassEmptyBootnodeList() { + parseCommand("--bootnodes"); + + verify(mockRunnerBuilder).bootstrapPeers(uriListArgumentCaptor.capture()); + verify(mockRunnerBuilder).build(); + + assertThat(uriListArgumentCaptor.getValue()).isEmpty(); + + assertThat(commandOutput.toString()).isEmpty(); + assertThat(commandErrorOutput.toString()).isEmpty(); + } + + @Ignore( + "NC-2015 - Temporarily enabling zero-arg --bootnodes to permit 'bootnode' configuration, which changes the error.") @Test public void callingWithInvalidBootnodesMustDisplayErrorAndUsage() { parseCommand("--bootnodes", "invalid_enode_url"); @@ -507,6 +523,14 @@ public class PantheonCommandTest extends CommandTestAbstract { assertThat(commandErrorOutput.toString()).startsWith(expectedErrorOutputStart); } + @Test + public void callingWithInvalidBootnodesAndZeroArityMustDisplayAlternateErrorAndUsage() { + parseCommand("--bootnodes", "invalid_enode_url"); + assertThat(commandOutput.toString()).isEmpty(); + final String expectedErrorOutputStart = "Unmatched argument: invalid_enode_url"; + assertThat(commandErrorOutput.toString()).startsWith(expectedErrorOutputStart); + } + @Test public void callingWithBannedNodeidsOptionButNoValueMustDisplayErrorAndUsage() { parseCommand("--banned-nodeids");