Fixed NetworkHandlerTest
This commit is contained in:
parent
409100ab20
commit
4913a21b11
@ -13,6 +13,12 @@ subprojects {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
}
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc
|
||||
|
@ -104,7 +104,7 @@ public class NetworkHandlerTest {
|
||||
10);
|
||||
t.join();
|
||||
assertEquals(3, nodeInventory.getInventory().size());
|
||||
assertEquals(3, peerInventory.getInventory().size());
|
||||
assertInventorySize(3, peerInventory);
|
||||
}
|
||||
|
||||
@Test(timeout = 5_000)
|
||||
@ -121,7 +121,7 @@ public class NetworkHandlerTest {
|
||||
10);
|
||||
t.join();
|
||||
assertEquals(2, nodeInventory.getInventory().size());
|
||||
assertEquals(2, peerInventory.getInventory().size());
|
||||
assertInventorySize(2, peerInventory);
|
||||
}
|
||||
|
||||
@Test(timeout = 10_000)
|
||||
@ -137,7 +137,7 @@ public class NetworkHandlerTest {
|
||||
10);
|
||||
t.join();
|
||||
assertEquals(1, nodeInventory.getInventory().size());
|
||||
assertEquals(1, peerInventory.getInventory().size());
|
||||
assertInventorySize(1, peerInventory);
|
||||
}
|
||||
|
||||
private void shutdown(BitmessageContext node) {
|
||||
@ -146,4 +146,12 @@ public class NetworkHandlerTest {
|
||||
Thread.yield();
|
||||
} while (node.isRunning());
|
||||
}
|
||||
|
||||
private void assertInventorySize(int expected, TestInventory inventory) throws InterruptedException {
|
||||
long timeout = System.currentTimeMillis() + 1000;
|
||||
while (expected != inventory.getInventory().size() && System.currentTimeMillis() < timeout) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
assertEquals(expected, inventory.getInventory().size());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user