From 8f6baf36d6c79e1f543ded40f712463109e47865 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 26 Jan 2016 11:34:25 +0100
Subject: [PATCH] Fix: Network tests sometimes failed

---
 app/lib/streams/bma.js       | 1 +
 test/integration/peerings.js | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/lib/streams/bma.js b/app/lib/streams/bma.js
index 2a35d73b6..f341b4a94 100644
--- a/app/lib/streams/bma.js
+++ b/app/lib/streams/bma.js
@@ -176,6 +176,7 @@ module.exports = function(server, interfaces, httpLogs) {
 
       closeConnections: function () {
         return Q.all(httpServers.map(function (httpServer) {
+          logger.info('uCoin server stop listening');
           return Q.nbind(httpServer.close, httpServer)();
         }));
       },
diff --git a/test/integration/peerings.js b/test/integration/peerings.js
index f4cb542c9..8a39a67b9 100644
--- a/test/integration/peerings.js
+++ b/test/integration/peerings.js
@@ -131,15 +131,15 @@ describe("Network", function() {
             until(s3, 'block', 1)
           ];
           // A block was successfully spread accross the network
-          s2.bma.closeConnections();
+          yield s2.bma.closeConnections();
           yield commitS1();
           yield [
             until(s3, 'block', 1)
           ];
-          s2.bma.reopenConnections();
           // Server 2 syncs block number 2 (it did not have it)
           yield sync(2, 2, s1, s2);
           yield s2.recomputeSelfPeer();
+          yield s2.bma.reopenConnections();
           yield [
             until(s2, 'block', 2),
             until(s3, 'block', 2),
-- 
GitLab