Updated the way of getting default ports in orion to use new options provided by Orion. (#660)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Rob Dawson 6 years ago committed by GitHub
parent 08d36864fa
commit b4e59972e9
  1. 2
      config/build.gradle
  2. 2
      orion/build.gradle
  3. 2
      orion/src/integration-test/java/tech/pegasys/pantheon/orion/OrionTest.java
  4. 2
      testutil/build.gradle
  5. 39
      testutil/src/main/java/tech/pegasys/orion/testutil/OrionTestHarness.java

@ -38,7 +38,7 @@ dependencies {
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'net.consensys:orion:0.1.0-SNAPSHOT'
testImplementation 'net.consensys:orion:0.1.1-SNAPSHOT'
}
configurations { testArtifacts }

@ -9,6 +9,6 @@ dependencies {
// integration test dependacies.
integrationTestImplementation 'junit:junit'
integrationTestImplementation project(':testutil')
integrationTestImplementation 'net.consensys:orion:0.1.0-SNAPSHOT'
integrationTestImplementation 'net.consensys:orion:0.1.1-SNAPSHOT'
}

@ -46,7 +46,7 @@ public class OrionTest {
testHarness = OrionTestHarness.create(folder.newFolder().toPath());
orion = new Orion(testHarness.getConfig().clientUrl().toString());
orion = new Orion(testHarness.clientUrl());
}
@AfterClass

@ -29,5 +29,5 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'com.squareup.okhttp3:okhttp'
implementation 'net.consensys:orion:0.1.0-SNAPSHOT'
implementation 'net.consensys:orion:0.1.1-SNAPSHOT'
}

@ -16,7 +16,6 @@ import static com.google.common.io.Files.readLines;
import static net.consensys.cava.io.file.Files.copyResource;
import java.io.IOException;
import java.net.ServerSocket;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
@ -24,6 +23,7 @@ import java.util.stream.Collectors;
import com.google.common.base.Charsets;
import net.consensys.orion.cmd.Orion;
import net.consensys.orion.config.Config;
import okhttp3.HttpUrl;
public class OrionTestHarness {
@ -40,12 +40,6 @@ public class OrionTestHarness {
public static OrionTestHarness create(final Path tempDir) throws Exception {
int nodePort = freePort();
int clientPort = freePort();
String nodeUrl = String.format("http://%s:%s", HOST, nodePort);
String clientUrl = String.format("http://%s:%s", HOST, clientPort);
Path key1pub = copyResource("orion_key_0.pub", tempDir.resolve("orion_key_0.pub"));
Path key1key = copyResource("orion_key_0.key", tempDir.resolve("orion_key_0.key"));
@ -57,28 +51,13 @@ public class OrionTestHarness {
"tls=\"off\"\n"
+ "tlsservertrust=\"tofu\"\n"
+ "tlsclienttrust=\"tofu\"\n"
+ "nodeurl = \""
+ nodeUrl
+ "\"\n"
+ "nodeport = "
+ nodePort
+ "\n"
+ "nodenetworkinterface = \""
+ HOST
+ "\"\n"
+ "clienturl = \""
+ clientUrl
+ "\"\n"
+ "clientport = "
+ clientPort
+ "\n"
+ "clientnetworkinterface = \""
+ HOST
+ "\"\n"
+ "storage = \"leveldb:database/orion_node\"\n"
+ "othernodes = [\""
+ nodeUrl
+ "\"]\n"
+ "publickeys = ["
+ joinPathsAsTomlListEntry(key1pub, key2pub)
+ "]\n"
@ -94,6 +73,7 @@ public class OrionTestHarness {
final Orion orion = new Orion();
orion.run(System.out, System.err, config);
return new OrionTestHarness(orion, config);
}
@ -130,12 +110,6 @@ public class OrionTestHarness {
}
}
private static int freePort() throws Exception {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
}
}
private static String joinPathsAsTomlListEntry(final Path... paths) {
StringBuilder builder = new StringBuilder();
boolean first = true;
@ -148,4 +122,13 @@ public class OrionTestHarness {
}
return builder.toString();
}
public String clientUrl() {
return new HttpUrl.Builder()
.scheme("http")
.host(HOST)
.port(orion.clientPort())
.build()
.toString();
}
}

Loading…
Cancel
Save