From 1fce4ed0ca1296e88da01c239c276815c9a30701 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Wed, 20 Sep 2017 17:23:19 +0200 Subject: [PATCH] [fix] Make tests pass since initial peersignal is delayed --- test/integration/tools/node.js | 4 +++- test/integration/tools/toolbox.ts | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/integration/tools/node.js b/test/integration/tools/node.js index bea8fb7b7..cb65f6ff4 100644 --- a/test/integration/tools/node.js +++ b/test/integration/tools/node.js @@ -131,7 +131,9 @@ function Node (dbName, options) { // Launching server that.server = server; started = true; - next(); + server.PeeringService.generateSelfPeer(server.conf, 0) + .then(() => next()) + .catch(next) }, function (next) { that.http = contacter(options.remoteipv4, options.remoteport); diff --git a/test/integration/tools/toolbox.ts b/test/integration/tools/toolbox.ts index 80708cd07..e28f3292d 100644 --- a/test/integration/tools/toolbox.ts +++ b/test/integration/tools/toolbox.ts @@ -674,11 +674,12 @@ export const simpleWS2PNetwork: (s1: TestingServer, s2: TestingServer) => Promis const cluster1 = WS2PCluster.plugOn(s1._server) const cluster2 = WS2PCluster.plugOn(s2._server) const ws2ps = await cluster1.listen('localhost', port) - const ws2pc = await cluster2.connect('localhost', port, new WS2PServerMessageHandler(s2._server, cluster2), s1._server.conf.pair.pub) - - await new Promise(res => { + const connexionPromise = new Promise(res => { ws2ps.on('newConnection', res) }) + const ws2pc = await cluster2.connect('localhost', port, new WS2PServerMessageHandler(s2._server, cluster2), s1._server.conf.pair.pub) + + await connexionPromise w1 = await ws2ps.getConnection(clientPub) if (!w1) { throw "Connection coming from " + clientPub + " was not found" -- GitLab