From 4a264dbdc73875cc480a63ecbd2f065a017f5e27 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Tue, 10 May 2016 15:30:55 +0200 Subject: [PATCH] Make use localhost a field in network stress test It will help with the recreation of peers for mailbox send test. --- .../java/io/bitsquare/p2p/network/NetworkStressTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java b/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java index eb1b219c21..7374ca4922 100644 --- a/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java +++ b/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java @@ -67,6 +67,8 @@ public class NetworkStressTest { /** A directory to (temporarily) hold seed and normal nodes' configuration and state files. */ private Path testDataDir; + /** Whether to use localhost addresses instead of Tor hidden services. */ + private boolean useLocalhost; /** A single seed node that other nodes will contact to request initial data. */ private SeedNode seedNode; /** The repository of seed nodes used in the test. */ @@ -126,7 +128,7 @@ public class NetworkStressTest { // Create and start the seed node. seedNode = new SeedNode(testDataDir.toString()); final NodeAddress seedNodeAddress = newSeedNodeAddress(); - final boolean useLocalhost = seedNodeAddress.hostName.equals("localhost"); + useLocalhost = seedNodeAddress.hostName.equals("localhost"); final Set seedNodes = new HashSet<>(1); seedNodes.add(seedNodeAddress); // the only seed node in tests seedNode.createAndStartP2PService(seedNodeAddress, SeedNode.MAX_CONNECTIONS_DEFAULT, useLocalhost, @@ -145,7 +147,7 @@ public class NetworkStressTest { final int peerPort = Utils.findFreeSystemPort(); peerPorts.add(peerPort); // create, save and start peer - final P2PService peer = createPeerNode(p, peerPort, useLocalhost); + final P2PService peer = createPeerNode(p, peerPort); //noinspection ConstantConditions peerPKRings.add(peer.getKeyRing().getPubKeyRing()); peerNodes.add(peer); @@ -176,7 +178,7 @@ public class NetworkStressTest { } @NotNull - private P2PService createPeerNode(int n, int port, boolean useLocalhost) { + private P2PService createPeerNode(int n, int port) { // peer data directories final File peerDir = new File(testDataDir.toFile(), String.format("peer-%06d", n)); final File peerTorDir = new File(peerDir, "tor");