Check reception of preliminary data in peers in network stress test

Need to check that the seed node boots first to avoid spurious failures.
This commit is contained in:
Ivan Vilata-i-Balaguer 2016-04-26 11:37:51 +02:00
parent a2d130219c
commit 1f2d755c64

View File

@ -31,6 +31,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class NetworkStressTest {
/** Numeric identifier of the regtest Bitcoin network. */
@ -45,6 +46,9 @@ public class NetworkStressTest {
/** A list of peer nodes represented as P2P services. */
private List<P2PService> peerNodes = new ArrayList<>();
/** A barrier to wait for concurrent reception of preliminary data in peers. */
private CountDownLatch prelimDataLatch = new CountDownLatch(NPEERS);
@Before
public void setUp() throws Exception {
/** A property where threads can indicate setup failure of local services (Tor node, hidden service). */
@ -113,7 +117,8 @@ public class NetworkStressTest {
return new P2PServiceListener() {
@Override
public void onRequestingDataCompleted() {
// do nothing
// successful result
NetworkStressTest.this.prelimDataLatch.countDown();
}
@Override
@ -174,8 +179,9 @@ public class NetworkStressTest {
@Test
public void test() throws InterruptedException {
// do nothing
Thread.sleep(30_000);
// Wait for peers to get their preliminary data.
org.junit.Assert.assertTrue("timed out while waiting for preliminary data",
prelimDataLatch.await(30, TimeUnit.SECONDS));
}
private Path createTempDirectory() throws IOException {