From 05d2242d247b0bd573fbabc2659236b99610568a Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 15 Feb 2015 22:06:51 +0100 Subject: [PATCH] Update to TomP2P Beta3 --- .../java/io/bitsquare/msg/TomP2PTests.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/bitsquare/msg/TomP2PTests.java b/src/test/java/io/bitsquare/msg/TomP2PTests.java index be1415c749..f138fc73ea 100644 --- a/src/test/java/io/bitsquare/msg/TomP2PTests.java +++ b/src/test/java/io/bitsquare/msg/TomP2PTests.java @@ -53,7 +53,9 @@ import net.tomp2p.p2p.Peer; import net.tomp2p.p2p.PeerBuilder; import net.tomp2p.peers.Number160; import net.tomp2p.peers.PeerAddress; -import net.tomp2p.relay.RelayConfig; +import net.tomp2p.peers.PeerMap; +import net.tomp2p.peers.PeerMapConfiguration; +import net.tomp2p.relay.tcp.TCPRelayClientConfig; import net.tomp2p.storage.Data; import org.junit.After; @@ -82,7 +84,7 @@ public class TomP2PTests { private static final Logger log = LoggerFactory.getLogger(TomP2PTests.class); // If you want to test in one specific connection mode define it directly, otherwise use UNKNOWN - private static final ConnectionType FORCED_CONNECTION_TYPE = ConnectionType.DIRECT; + private static final ConnectionType FORCED_CONNECTION_TYPE = ConnectionType.RELAY; // Typically you run the bootstrap node in localhost to test direct connection. // If you have a setup where you are not behind a router you can also use a WAN bootstrap node. @@ -293,9 +295,23 @@ public class TomP2PTests { @Test @Repeat(STRESS_TEST_COUNT) public void testParallelStartupWithPutGet() throws IOException, ClassNotFoundException, InterruptedException { + PeerMapConfiguration pmc1 = new PeerMapConfiguration(Number160.createHash("peer1")).peerNoVerification(); + PeerMap pm1 = new PeerMap(pmc1); + + PeerDHT peer1 = new PeerBuilderDHT(new PeerBuilder(Number160.createHash("peer1")).ports(3006).peerMap(pm1).start()).start(); + + PeerMapConfiguration pmc2 = new PeerMapConfiguration(Number160.createHash("peer2")).peerNoVerification(); + PeerMap pm2 = new PeerMap(pmc2); + + PeerDHT peer2 = new PeerBuilderDHT(new PeerBuilder(Number160.createHash("peer2")).ports(3007).peerMap(pm2).start()).start(); + + /* PeerAddress masterPeerAddress = new PeerAddress(Number160.createHash(BOOTSTRAP_NODE_ID), + BOOTSTRAP_NODE_IP, BOOTSTRAP_NODE_PORT, + BOOTSTRAP_NODE_PORT); + PeerDHT peer1 = new PeerBuilderDHT(new PeerBuilder(Number160.createHash("peer1")).ports(3006).start()).start(); PeerDHT peer2 = new PeerBuilderDHT(new PeerBuilder(Number160.createHash("peer2")).ports(3007).start()).start(); - +*/ PeerAddress masterPeerAddress = new PeerAddress(Number160.createHash(BootstrapNodes.LOCALHOST.getName()), BootstrapNodes.LOCALHOST.getIp(), BootstrapNodes.LOCALHOST.getPort(), BootstrapNodes.LOCALHOST.getPort()); @@ -315,6 +331,7 @@ public class TomP2PTests { @Override public void exceptionCaught(Throwable t) throws Exception { + log.error(t.toString()); } }); @@ -326,6 +343,7 @@ public class TomP2PTests { @Override public void exceptionCaught(Throwable t) throws Exception { + log.error(t.toString()); } }); @@ -520,7 +538,9 @@ public class TomP2PTests { FutureDirect futureDirect = peer1DHT.peer().sendDirect(futurePeerConnection).object("hallo").start(); futureDirect.awaitUninterruptibly(); assertTrue(futureDirect.isSuccess()); - assertEquals("pong", futureDirect.object()); + + // server node does not reply + // assertEquals("pong", futureDirect.object()); } private Peer bootstrapDirectConnection(int clientPort) { @@ -647,7 +667,7 @@ public class TomP2PTests { PeerNAT peerNAT = new PeerBuilderNAT(peer).start(); FutureDiscover futureDiscover = peer.discover().peerAddress(BOOTSTRAP_NODE_ADDRESS).start(); FutureNAT futureNAT = peerNAT.startSetupPortforwarding(futureDiscover); - FutureRelayNAT futureRelayNAT = peerNAT.startRelay(RelayConfig.OpenTCP(), futureDiscover, futureNAT); + FutureRelayNAT futureRelayNAT = peerNAT.startRelay(new TCPRelayClientConfig(), futureDiscover, futureNAT); futureRelayNAT.awaitUninterruptibly(); if (futureRelayNAT.isSuccess()) { log.info("Bootstrap using relay was successful. Address = " + peer.peerAddress());