Use absolute data-path instead of relative. (#894)

When using the data-path internally use an absolute version instead of the path instead of a relative form.  

This fixes a null pointer exception when the data-path is set to an empty string (in a TOML config using `data-path=""` or CLI using `--data-path=`) and interprets that empty string to be the current working directory.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent 7c97318f28
commit b7761de2a3
  1. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  2. 7
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -933,7 +933,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
private Path dataDir() {
if (isFullInstantiation()) {
return standaloneCommands.dataPath;
return standaloneCommands.dataPath.toAbsolutePath();
} else if (isDocker) {
return Paths.get(DOCKER_DATADIR_LOCATION);
} else {

@ -303,7 +303,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
.setGenesisConfig(encodeJsonGenesis(GENESIS_VALID_JSON))
.setBootNodes(nodes)
.build();
verify(mockControllerBuilder).homePath(eq(Paths.get("~/pantheondata")));
verify(mockControllerBuilder).homePath(eq(Paths.get("~/pantheondata").toAbsolutePath()));
verify(mockControllerBuilder).ethNetworkConfig(eq(networkConfig));
verify(mockControllerBuilder).syncWithOttoman(eq(false));
@ -505,10 +505,11 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).homePath(pathArgumentCaptor.capture());
verify(mockControllerBuilder).syncWithOttoman(eq(false));
verify(mockControllerBuilder).nodePrivateKeyFile(eq(path.resolve("key").toFile()));
verify(mockControllerBuilder)
.nodePrivateKeyFile(eq(path.resolve("key").toAbsolutePath().toFile()));
verify(mockControllerBuilder).build();
assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(path);
assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(path.toAbsolutePath());
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();

Loading…
Cancel
Save