mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-26 08:25:23 -04:00
Use compatible version with latest TomP2P lib
This commit is contained in:
parent
7049ab3a78
commit
089be0ca16
4 changed files with 74 additions and 82 deletions
|
@ -218,14 +218,14 @@ class TomP2PMessageFacade implements MessageFacade {
|
|||
}
|
||||
}
|
||||
}));
|
||||
if (isSuccess(removeFuture)) {
|
||||
|
||||
// We don't test futureRemove.isSuccess() as this API does not fit well to that operation,
|
||||
// it might change in future to something like foundAndRemoved and notFound
|
||||
// See discussion at: https://github.com/tomp2p/TomP2P/issues/57#issuecomment-62069840
|
||||
|
||||
log.trace("Remove arbitrator from DHT was successful. Stored data: [key: " + locationKey + ", " +
|
||||
"values: " + arbitratorData + "]");
|
||||
}
|
||||
else {
|
||||
log.error("Remove arbitrators from DHT failed with reason:" + removeFuture.failedReason());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,10 @@ class TomP2POfferRepository implements OfferRepository {
|
|||
futureRemove.addListener(new BaseFutureListener<BaseFuture>() {
|
||||
@Override
|
||||
public void operationComplete(BaseFuture future) throws Exception {
|
||||
if (isSuccess(future)) {
|
||||
// We don't test futureRemove.isSuccess() as this API does not fit well to that operation,
|
||||
// it might change in future to something like foundAndRemoved and notFound
|
||||
// See discussion at: https://github.com/tomp2p/TomP2P/issues/57#issuecomment-62069840
|
||||
|
||||
Platform.runLater(() -> {
|
||||
offerRepositoryListeners.stream().forEach(listener -> {
|
||||
try {
|
||||
|
@ -147,7 +150,6 @@ class TomP2POfferRepository implements OfferRepository {
|
|||
writeInvalidationTimestampToDHT(locationKey);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(Throwable t) throws Exception {
|
||||
|
|
|
@ -83,7 +83,8 @@ public class TomP2PTests {
|
|||
// Typically you run the seed 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 side seed node.
|
||||
private static final Node BOOTSTRAP_NODE =
|
||||
(FORCED_CONNECTION_TYPE == ConnectionType.DIRECT) ? BootstrapNodes.LOCALHOST : BootstrapNodes.DIGITAL_OCEAN_1;
|
||||
(FORCED_CONNECTION_TYPE == ConnectionType.DIRECT) ? BootstrapNodes.LOCALHOST : BootstrapNodes
|
||||
.DIGITAL_OCEAN_1;
|
||||
|
||||
private static final PeerAddress BOOTSTRAP_NODE_ADDRESS;
|
||||
|
||||
|
@ -163,7 +164,6 @@ public class TomP2PTests {
|
|||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
FuturePut futurePut = peer1DHT.put(Number160.createHash("key")).data(new Data("hallo")).start();
|
||||
futurePut.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut.isSuccess());
|
||||
}
|
||||
|
||||
|
@ -173,14 +173,12 @@ public class TomP2PTests {
|
|||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
FuturePut futurePut = peer1DHT.put(Number160.createHash("key")).data(new Data("hallo")).start();
|
||||
futurePut.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut.isSuccess());
|
||||
|
||||
|
||||
peer2DHT = getDHTPeer("node_2", client2Port);
|
||||
FutureGet futureGet = peer2DHT.get(Number160.createHash("key")).start();
|
||||
futureGet.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futureGet.isSuccess());
|
||||
assertEquals("hallo", futureGet.data().object());
|
||||
}
|
||||
|
@ -191,12 +189,10 @@ public class TomP2PTests {
|
|||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
FuturePut futurePut1 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo1")).start();
|
||||
futurePut1.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut1.isSuccess());
|
||||
|
||||
FuturePut futurePut2 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo2")).start();
|
||||
futurePut2.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut2.isSuccess());
|
||||
}
|
||||
|
||||
|
@ -206,19 +202,16 @@ public class TomP2PTests {
|
|||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
FuturePut futurePut1 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo1")).start();
|
||||
futurePut1.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut1.isSuccess());
|
||||
|
||||
FuturePut futurePut2 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo2")).start();
|
||||
futurePut2.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut2.isSuccess());
|
||||
|
||||
|
||||
peer2DHT = getDHTPeer("node_2", client2Port);
|
||||
FutureGet futureGet = peer2DHT.get(Number160.createHash("locationKey")).all().start();
|
||||
futureGet.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futureGet.isSuccess());
|
||||
|
||||
assertTrue(futureGet.dataMap().values().contains(new Data("hallo1")));
|
||||
|
@ -232,12 +225,10 @@ public class TomP2PTests {
|
|||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
FuturePut futurePut1 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo1")).start();
|
||||
futurePut1.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut1.isSuccess());
|
||||
|
||||
FuturePut futurePut2 = peer1DHT.add(Number160.createHash("locationKey")).data(new Data("hallo2")).start();
|
||||
futurePut2.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futurePut2.isSuccess());
|
||||
|
||||
|
||||
|
@ -247,13 +238,12 @@ public class TomP2PTests {
|
|||
.start();
|
||||
futureRemove.awaitUninterruptibly();
|
||||
|
||||
// That fails sometimes in direct mode and NAT
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futureRemove.isSuccess());
|
||||
// We don't test futureRemove.isSuccess() as this API does not fit well to that operation,
|
||||
// it might change in future to something like foundAndRemoved and notFound
|
||||
// See discussion at: https://github.com/tomp2p/TomP2P/issues/57#issuecomment-62069840
|
||||
|
||||
FutureGet futureGet = peer2DHT.get(Number160.createHash("locationKey")).all().start();
|
||||
futureGet.awaitUninterruptibly();
|
||||
if (shouldEvaluateSuccess())
|
||||
assertTrue(futureGet.isSuccess());
|
||||
|
||||
assertTrue(futureGet.dataMap().values().contains(new Data("hallo2")));
|
||||
|
@ -267,7 +257,7 @@ public class TomP2PTests {
|
|||
@Test
|
||||
@Repeat(STRESS_TEST_COUNT)
|
||||
public void testSendDirectBetweenLocalPeers() throws Exception {
|
||||
if (FORCED_CONNECTION_TYPE != ConnectionType.NAT && resolvedConnectionType != ConnectionType.NAT) {
|
||||
// if (FORCED_CONNECTION_TYPE != ConnectionType.NAT && resolvedConnectionType != ConnectionType.NAT) {
|
||||
peer1DHT = getDHTPeer("node_1", client1Port);
|
||||
peer2DHT = getDHTPeer("node_2", client2Port);
|
||||
|
||||
|
@ -293,7 +283,7 @@ public class TomP2PTests {
|
|||
assertTrue(futureDirect.isSuccess());
|
||||
log.debug(futureDirect.object().toString());
|
||||
assertEquals("pong", futureDirect.object());
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// That test should always succeed as we use the server seed node as receiver.
|
||||
|
@ -478,8 +468,4 @@ public class TomP2PTests {
|
|||
|
||||
return newPort;
|
||||
}
|
||||
|
||||
private boolean shouldEvaluateSuccess() {
|
||||
return FORCED_CONNECTION_TYPE == ConnectionType.NAT || resolvedConnectionType == ConnectionType.NAT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,7 +337,11 @@ public class TomP2PNodeTest {
|
|||
node = new TomP2PNode(keyPairClient, client);
|
||||
FutureRemove futureRemove = node.removeFromDataMap(locationKey, data_1);
|
||||
futureRemove.awaitUninterruptibly();
|
||||
assertTrue(futureRemove.isSuccess());
|
||||
|
||||
// We don't test futureRemove.isSuccess() as this API does not fit well to that operation,
|
||||
// it might change in future to something like foundAndRemoved and notFound
|
||||
// See discussion at: https://github.com/tomp2p/TomP2P/issues/57#issuecomment-62069840
|
||||
|
||||
|
||||
futureGet = node.getDataMap(locationKey);
|
||||
futureGet.awaitUninterruptibly();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue