Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Default node key location should always be under data dir #265

Merged
merged 2 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public static class RpcApisConversionException extends Exception {
names = {"--node-private-key"},
paramLabel = MANDATORY_PATH_FORMAT_HELP,
description =
"the path to the node's private key file. (default: a file named \"key\" in the Pantheon data folder.)"
"the path to the node's private key file (default: a file named \"key\" in the Pantheon data folder)"
)
private final File nodePrivateKeyFile = KeyPairUtil.getDefaultKeyFile(dataDir);
private final File nodePrivateKeyFile = null;

// Genesis file path with null default option if the option
// is not defined on command line as this default is handled by Runner
Expand Down Expand Up @@ -452,14 +452,18 @@ PantheonController<?> buildController() {
syncWithOttoman,
new MiningParameters(coinbase, minTransactionGasPrice, extraData, isMiningEnabled),
isDevMode,
nodePrivateKeyFile);
getNodePrivateKeyFile());
} catch (final InvalidConfigurationException e) {
throw new ExecutionException(new CommandLine(this), e.getMessage());
} catch (final IOException e) {
throw new ExecutionException(new CommandLine(this), "Invalid path", e);
}
}

private File getNodePrivateKeyFile() {
return nodePrivateKeyFile != null ? nodePrivateKeyFile : KeyPairUtil.getDefaultKeyFile(dataDir);
}

private JsonRpcConfiguration jsonRpcConfiguration() {
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.setEnabled(isJsonRpcEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,14 @@ public void dataDirOptionMustBeUsed() throws Exception {
parseCommand("--datadir", path.toString());

verify(mockControllerBuilder)
.build(any(), pathArgumentCaptor.capture(), any(), eq(false), any(), anyBoolean(), any());
.build(
any(),
pathArgumentCaptor.capture(),
any(),
eq(false),
any(),
anyBoolean(),
eq(path.resolve("key").toFile()));

assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(path);

Expand Down