mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-02 19:56:23 -04:00
Split network stress tests in direct and mailbox
Now they can be run independently.
This commit is contained in:
parent
c67f724e0f
commit
4b75235f33
1 changed files with 9 additions and 5 deletions
|
@ -226,9 +226,9 @@ public class NetworkStressTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Test each peer sending a direct message to another random peer. */
|
||||||
@Test
|
@Test
|
||||||
public void test() throws InterruptedException {
|
public void test_direct() throws InterruptedException {
|
||||||
// Test each peer sending a direct message to another random peer.
|
|
||||||
final int nPeers = peerNodes.size();
|
final int nPeers = peerNodes.size();
|
||||||
BooleanProperty sentDirectFailed = new SimpleBooleanProperty(false);
|
BooleanProperty sentDirectFailed = new SimpleBooleanProperty(false);
|
||||||
final List<Long> sentDelays = new Vector<>(nPeers * directCount);
|
final List<Long> sentDelays = new Vector<>(nPeers * directCount);
|
||||||
|
@ -298,8 +298,11 @@ public class NetworkStressTest {
|
||||||
directCount, (System.currentTimeMillis() - sendStartMillis) / 1000.0,
|
directCount, (System.currentTimeMillis() - sendStartMillis) / 1000.0,
|
||||||
mma.first, mma.second, mma.third);
|
mma.first, mma.second, mma.third);
|
||||||
org.junit.Assert.assertFalse("some peer(s) failed to send a direct message", sentDirectFailed.get());
|
org.junit.Assert.assertFalse("some peer(s) failed to send a direct message", sentDirectFailed.get());
|
||||||
|
}
|
||||||
|
|
||||||
// Test sending and receiving mailbox messages.
|
/** Test sending and receiving mailbox messages. */
|
||||||
|
@Test
|
||||||
|
public void test_mailbox() throws InterruptedException {
|
||||||
// We start by putting the first half of peers online and the second one offline.
|
// We start by putting the first half of peers online and the second one offline.
|
||||||
// Then the first online peer sends a number of messages to random peers (regardless of their state),
|
// Then the first online peer sends a number of messages to random peers (regardless of their state),
|
||||||
// so that some messages are delivered directly and others into a mailbox.
|
// so that some messages are delivered directly and others into a mailbox.
|
||||||
|
@ -353,6 +356,7 @@ public class NetworkStressTest {
|
||||||
});
|
});
|
||||||
bootLatch.await();
|
bootLatch.await();
|
||||||
|
|
||||||
|
final int nPeers = peerNodes.size();
|
||||||
for (int firstOnline = 0, firstOffline = (int)Math.ceil(nPeers/2.0);
|
for (int firstOnline = 0, firstOffline = (int)Math.ceil(nPeers/2.0);
|
||||||
firstOnline < nPeers;
|
firstOnline < nPeers;
|
||||||
firstOnline++, firstOffline = ++firstOffline%nPeers) {
|
firstOnline++, firstOffline = ++firstOffline%nPeers) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue