From 68ef5454e02bb479a6a63723462dc3e589672e28 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Mon, 10 Sep 2018 11:52:06 +0100 Subject: [PATCH 1/2] Avoid multiple connect to IPC --- lib/tests/test.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 8c61b15aa..c43d27c3b 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -144,26 +144,27 @@ class Test { self.engine.startService("codeCoverage"); if (self.options.node === 'embark') { - return self.engine.ipc.connect((err) => { - if (err) { - this.engine.logger.error(err.message || err); - this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?"); - process.exit(1); - } - self.engine.ipc.request('blockchain:node', {}, (err, node) => { - if (err) { - return self.engine.logger.error(err.message || err); - } - self.options.node = node; - cb(); - }); - }); + if (!self.engine.ipc.connected) { + self.engine.logger.error("Could not connect to Embark's IPC. Is embark running?"); + process.exit(1); + } + return self.connectToIpcNode(cb); } cb(); } ], callback); } + connectToIpcNode(cb) { + this.engine.ipc.request('blockchain:node', {}, (err, node) => { + if (err) { + return this.engine.logger.error(err.message || err); + } + this.options.node = node; + cb(); + }); + } + onReady(callback) { const self = this; if (this.ready) { From 32a6b53c6ae5fe193e2aa56d3e6f48650dc9b5d4 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Mon, 10 Sep 2018 17:05:11 +0100 Subject: [PATCH 2/2] Add missing callback --- lib/tests/test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index c43d27c3b..f83f276e9 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -158,7 +158,8 @@ class Test { connectToIpcNode(cb) { this.engine.ipc.request('blockchain:node', {}, (err, node) => { if (err) { - return this.engine.logger.error(err.message || err); + this.engine.logger.error(err.message || err); + return cb(); } this.options.node = node; cb();