diff --git a/build.gradle b/build.gradle index 0e1e063..02a3903 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,12 @@ subprojects { mavenCentral() } + test { + testLogging { + exceptionFormat = 'full' + } + } + task javadocJar(type: Jar) { classifier = 'javadoc' from javadoc diff --git a/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java b/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java index 7ba8fc4..ee437e1 100644 --- a/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java +++ b/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java @@ -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()); + } }