Skip to content

Commit

Permalink
add a cli test for port&Info input
Browse files Browse the repository at this point in the history
  • Loading branch information
beidouz committed Dec 7, 2018
1 parent 579c3f4 commit 6432825
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modAionImpl/src/org/aion/zero/impl/cli/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public ReturnType call(final String[] args, Cfg cfg) {
// true means the UUID must be set
boolean overwrite = cfg.fromXML(configFile);

// port option can be used with the -n, -d, -c, -i arguments
// determine the port configuration, can be combined with the -n, -d, -c, -i arguments
if (options.getPort() != null) {

int currentPort = cfg.getNet().getP2p().getPort();
Expand All @@ -216,13 +216,12 @@ public ReturnType call(final String[] args, Cfg cfg) {
overwrite = true;
System.out.println("Port set to: " + portNumber);
} else {
System.out.println(
"Using the current port configuration: " + currentPort);
System.out.println("Using the current port configuration: " + currentPort);
}
// no return, allow for other parameters combined with -c, -p
// no return, allow for other parameters combined with -p
}

// 4. can be influenced by the -d argument above
// 4. can be influenced by the -n, -d, -p arguments above

if (options.getConfig() != null) {
// network was already set above
Expand Down Expand Up @@ -260,7 +259,7 @@ public ReturnType call(final String[] args, Cfg cfg) {
return ReturnType.EXIT;
}

// 5. options that can be influenced by the -d and -n arguments
// 5. options that can be influenced by the -d, -n and -p arguments

if (options.isInfo()) {
System.out.println(
Expand Down
23 changes: 23 additions & 0 deletions modAionImpl/test/org/aion/zero/impl/cli/CliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public void shutdown() {
deleteRecursively(path);
deleteRecursively(alternativePath);

// in case absolute paths are used
deleteRecursively(cfg.getKeystoreDir());
deleteRecursively(cfg.getDatabaseDir());
deleteRecursively(cfg.getLogDir());

// to avoid deleting config for all tests
if (BASE_PATH.contains(module)) {
deleteRecursively(CONFIG_PATH);
Expand Down Expand Up @@ -977,8 +982,26 @@ private Object parametersWithInfo() {
parameters.add(new Object[] {new String[] {op, "-p", INVALID_PORT}, EXIT, expOnError});
}

// with port and directory
expected = new File(path, "mainnet").getAbsolutePath();
for (String op : options) {
// with relative path
parameters.add(
new Object[] {
new String[] {op, "-d", dataDirectory, "-p", TEST_PORT}, EXIT, expected
});
// with absolute path
parameters.add(
new Object[] {
new String[] {op, "-p", TEST_PORT, "-d", path.getAbsolutePath()},
EXIT,
expected
});
}

// with network and directory
expected = new File(path, "mastery").getAbsolutePath();

for (String op : options) {
// with relative path
parameters.add(
Expand Down

0 comments on commit 6432825

Please sign in to comment.