From 35077243b0a8f8ad83f39667c1dd983069940c28 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sun, 17 Jan 2016 07:13:29 +0100 Subject: [PATCH] Fixed synchronization --- .../java/ch/dissem/bitmessage/networking/Connection.java | 2 +- .../dissem/bitmessage/networking/NetworkHandlerTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/networking/src/main/java/ch/dissem/bitmessage/networking/Connection.java b/networking/src/main/java/ch/dissem/bitmessage/networking/Connection.java index 3155645..176517b 100644 --- a/networking/src/main/java/ch/dissem/bitmessage/networking/Connection.java +++ b/networking/src/main/java/ch/dissem/bitmessage/networking/Connection.java @@ -350,7 +350,7 @@ class Connection { send(new Version.Builder().defaults().addrFrom(host).addrRecv(node).build()); } while (state != DISCONNECTED) { - if (requestedObjects.isEmpty()) { + if (mode != SYNC && state == ACTIVE && requestedObjects.isEmpty()) { Thread.sleep(1000); } else { Thread.sleep(100); 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 e850ffb..77cad46 100644 --- a/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java +++ b/networking/src/test/java/ch/dissem/bitmessage/networking/NetworkHandlerTest.java @@ -94,7 +94,7 @@ public class NetworkHandlerTest { } while (node.isRunning()); } - @Test(timeout = 20_000) + @Test(timeout = 5_000) public void ensureNodesAreConnecting() { try { node.startup(); @@ -109,7 +109,7 @@ public class NetworkHandlerTest { } } - @Test(timeout = 10_000) + @Test(timeout = 5_000) public void ensureObjectsAreSynchronizedIfBothHaveObjects() throws Exception { peerInventory.init( "V4Pubkey.payload", @@ -128,7 +128,7 @@ public class NetworkHandlerTest { assertInventorySize(3, peerInventory); } - @Test(timeout = 10_000) + @Test(timeout = 5_000) public void ensureObjectsAreSynchronizedIfOnlyPeerHasObjects() throws Exception { peerInventory.init( "V4Pubkey.payload", @@ -145,7 +145,7 @@ public class NetworkHandlerTest { assertInventorySize(2, peerInventory); } - @Test(timeout = 10_000) + @Test(timeout = 5_000) public void ensureObjectsAreSynchronizedIfOnlyNodeHasObjects() throws Exception { peerInventory.init();