mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-14 23:44:51 -05:00
test update (WIP)
This commit is contained in:
parent
e219331e28
commit
ae65561623
1 changed files with 56 additions and 6 deletions
|
|
@ -30,6 +30,8 @@ public class PeerServiceTest {
|
||||||
private SeedNode seedNode1, seedNode2, seedNode3;
|
private SeedNode seedNode1, seedNode2, seedNode3;
|
||||||
private Set<NodeAddress> seedNodeAddresses = new HashSet<>();
|
private Set<NodeAddress> seedNodeAddresses = new HashSet<>();
|
||||||
private List<SeedNode> seedNodes = new ArrayList<>();
|
private List<SeedNode> seedNodes = new ArrayList<>();
|
||||||
|
private String test_dummy_dir = "test_dummy_dir";
|
||||||
|
;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws InterruptedException {
|
public void setup() throws InterruptedException {
|
||||||
|
|
@ -57,6 +59,8 @@ public class PeerServiceTest {
|
||||||
|
|
||||||
seedNodes.stream().forEach(seedNode -> {
|
seedNodes.stream().forEach(seedNode -> {
|
||||||
CountDownLatch shutDownLatch = new CountDownLatch(1);
|
CountDownLatch shutDownLatch = new CountDownLatch(1);
|
||||||
|
seedNode.getSeedNodeP2PService().shutDown(() -> {
|
||||||
|
});
|
||||||
seedNode.shutDown(shutDownLatch::countDown);
|
seedNode.shutDown(shutDownLatch::countDown);
|
||||||
try {
|
try {
|
||||||
shutDownLatch.await();
|
shutDownLatch.await();
|
||||||
|
|
@ -67,16 +71,61 @@ public class PeerServiceTest {
|
||||||
seedNodeAddresses.clear();
|
seedNodeAddresses.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleSeedNode() throws InterruptedException {
|
public void testSingleSeedNode() throws InterruptedException {
|
||||||
LocalhostNetworkNode.setSimulateTorDelayTorNode(0);
|
LocalhostNetworkNode.setSimulateTorDelayTorNode(0);
|
||||||
LocalhostNetworkNode.setSimulateTorDelayHiddenService(0);
|
LocalhostNetworkNode.setSimulateTorDelayHiddenService(0);
|
||||||
seedNodeAddresses.clear();
|
seedNodeAddresses.clear();
|
||||||
NodeAddress nodeAddress = new NodeAddress("localhost:8001");
|
|
||||||
seedNodeAddresses.add(nodeAddress);
|
for (int i = 0; i < 10; i++) {
|
||||||
SeedNode seedNode = new SeedNode("test_dummy_dir");
|
int port = 8000 + i;
|
||||||
seedNodes.add(seedNode);
|
NodeAddress nodeAddress = new NodeAddress("localhost:" + port);
|
||||||
latch = new CountDownLatch(2);
|
seedNodeAddresses.add(nodeAddress);
|
||||||
|
SeedNode seedNode = new SeedNode(test_dummy_dir);
|
||||||
|
seedNodes.add(seedNode);
|
||||||
|
seedNode.createAndStartP2PService(true);
|
||||||
|
seedNode.getSeedNodeP2PService().start(new P2PServiceListener() {
|
||||||
|
@Override
|
||||||
|
public void onRequestingDataCompleted() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNoSeedNodeAvailable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNoPeersAvailable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBootstrapComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTorNodeReady() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHiddenServicePublished() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetupFailed(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Thread.sleep(30_000);
|
||||||
|
|
||||||
|
/* latch = new CountDownLatch(2);
|
||||||
|
|
||||||
seedNode.createAndStartP2PService(nodeAddress, useLocalhost, 2, true,
|
seedNode.createAndStartP2PService(nodeAddress, useLocalhost, 2, true,
|
||||||
seedNodeAddresses, new P2PServiceListener() {
|
seedNodeAddresses, new P2PServiceListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -110,9 +159,10 @@ public class PeerServiceTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
P2PService p2PService = seedNode.getSeedNodeP2PService();
|
P2PService p2PService = seedNode.getSeedNodeP2PService();
|
||||||
latch.await();
|
latch.await();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);*/
|
||||||
|
|
||||||
//Assert.assertEquals(0, p2PService1.getPeerManager().getAuthenticatedAndReportedPeers().size());
|
//Assert.assertEquals(0, p2PService1.getPeerManager().getAuthenticatedAndReportedPeers().size());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue