Avoid multiple connect to IPC

This commit is contained in:
Anthony Laibe 2018-09-10 11:52:06 +01:00
parent 8c3ac34fac
commit 68ef5454e0
1 changed files with 15 additions and 14 deletions

View File

@ -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) {