diff --git a/lib/core/engine.js b/lib/core/engine.js index 8403af32..53dc4a3f 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -99,7 +99,7 @@ class Engine { processManagerService(_options) { const ProcessManager = require('../processes/processManager.js'); - const processManager = new ProcessManager({ + this.processManager = new ProcessManager({ events: this.events, logger: this.logger, plugins: this.plugins diff --git a/lib/modules/blockchain_process/index.js b/lib/modules/blockchain_process/index.js index a57d52be..043e0c1c 100644 --- a/lib/modules/blockchain_process/index.js +++ b/lib/modules/blockchain_process/index.js @@ -6,7 +6,6 @@ const BlockchainProcessLauncher = require('./blockchainProcessLauncher'); class BlockchainModule { constructor(embark, options) { - const self = this; this.logger = embark.logger; this.events = embark.events; this.blockchainConfig = embark.config.blockchainConfig; @@ -41,14 +40,12 @@ class BlockchainModule { cb = noLogs; noLogs = false; } - const NO_NODE_ERROR = Error("error connecting to blockchain node"); const self = this; async.waterfall([ // check if web3 is set // function checkWeb3State(next) { - console.dir("checkWeb3State"); self.events.request("blockchain:web3:isReady", (connected) => { console.dir("---> checking web3 state"); console.dir(connected.toString()); @@ -56,44 +53,20 @@ class BlockchainModule { return next(connected); } next(); - }) + }); }, - //function checkInstance(next) { - // if (!self.web3) { - // return next(Error("no web3 instance found")); - // } - // next(); - //}, - //function checkProvider(next) { - // if (self.web3.currentProvider === undefined) { - // return next(NO_NODE_ERROR); - // } - // next(); - //}, function pingEndpoint(next) { - console.dir("pingEndpoint"); if (!self.contractsConfig || !self.contractsConfig.deployment || !self.contractsConfig.deployment.host) { return next(); } const {host, port, type, protocol} = self.contractsConfig.deployment; - console.dir("||||| pinging: "); - console.dir(self.contractsConfig.deployment); utils.pingEndpoint(host, port, type, protocol, self.blockchainConfig.wsOrigins.split(',')[0], next); } - ], function (err, result) { - console.dir("------"); - console.dir(result); - console.dir("------"); + ], function (err, _result) { if (err === true || err === undefined) { return cb(true); } return cb(false); - - //if (!noLogs && err === NO_NODE_ERROR) { - // self.logger.error(("Couldn't connect to an Ethereum node are you sure it's on?").red); - // self.logger.info("make sure you have an Ethereum node or simulator running. e.g 'embark blockchain'".magenta); - //} - //cb(err); }); } diff --git a/lib/modules/storage/storageProcessesLauncher.js b/lib/modules/storage/storageProcessesLauncher.js index cac28f57..eb7c07da 100644 --- a/lib/modules/storage/storageProcessesLauncher.js +++ b/lib/modules/storage/storageProcessesLauncher.js @@ -8,7 +8,7 @@ const {canonicalHost} = require('../../utils/host'); let References = { ipfs: 'https://ipfs.io/docs/install/', swarm: 'http://swarm-guide.readthedocs.io/en/latest/installation.html' -} +}; class StorageProcessesLauncher { constructor(options) { diff --git a/lib/processes/processManager.js b/lib/processes/processManager.js index 4da9ddea..32a083ca 100644 --- a/lib/processes/processManager.js +++ b/lib/processes/processManager.js @@ -8,29 +8,25 @@ class ProcessManager { this.processes = {}; self.events.setCommandHandler('processes:register', (name, cb) => { - console.dir("=====> registering " + name); this.processes[name] = { state: 'unstarted', cb: cb - } + }; }); self.events.setCommandHandler('processes:launch', (name, cb) => { let process = self.processes[name]; - // TODO: should make distinction between starting and running if (process.state != 'unstarted') { console.dir("=====> already started " + name); return cb(); } - console.dir("=====> launching " + name); process.state = 'starting'; - //let pry = require('pryjs'); - //eval(pry.it); - process.cb.apply(process.cb, [() => { - process.state = 'running'; - console.dir("=====> launched " + name); - cb(); - }]); + process.cb.apply(process.cb, [ + () => { + process.state = 'running'; + cb(); + } + ]); }); } diff --git a/test/blockchain.js b/test/blockchain.js index 36e1f688..19ab6ead 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -1,5 +1,5 @@ /*globals describe, it*/ -const Blockchain = require('../lib/cmds/blockchain/blockchain'); +const Blockchain = require('../lib/modules/blockchain_process/blockchain.js'); const constants = require('../lib/constants.json'); const {defaultHost} = require('../lib/utils/host'); diff --git a/test/contracts.js b/test/contracts.js index a8a88327..cd999376 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -1,6 +1,6 @@ /*globals describe, it*/ let ContractsManager = require('../lib/contracts/contracts.js'); -let Compiler = require('../lib/contracts/compiler.js'); +let Compiler = require('../lib/modules/compiler/'); let Logger = require('../lib/core/logger.js'); let File = require('../lib/core/file.js'); let TestLogger = require('../lib/tests/test_logger.js'); @@ -37,11 +37,11 @@ describe('embark.Contracts', function() { }); plugins.loadInternalPlugin('solidity', {ipc: ipcObject}); - let compiler = new Compiler({plugins: plugins, logger: plugins.logger}); let events = new Events(); - events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { - compiler.compile_contracts(contractFiles, cb); - }); + let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins}); + //events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { + // compiler.compile_contracts(contractFiles, cb); + //}); events.setCommandHandler("config:contractsConfig", function(cb) { cb(contractsConfig); @@ -146,11 +146,8 @@ describe('embark.Contracts', function() { }); plugins.loadInternalPlugin('solidity', {ipc: ipcObject}); - let compiler = new Compiler({plugins: plugins, logger: plugins.logger}); let events = new Events(); - events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { - compiler.compile_contracts(contractFiles, cb); - }); + let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins}); events.setCommandHandler("config:contractsConfig", function(cb) { cb(contractsConfig); diff --git a/test/processLauncher.js b/test/processLauncher.js index d77f8f25..56d5c58e 100644 --- a/test/processLauncher.js +++ b/test/processLauncher.js @@ -2,8 +2,8 @@ const assert = require('assert'); const sinon = require('sinon'); const TestLogger = require('../lib/tests/test_logger'); -const ProcessLauncher = require('../lib/process/processLauncher'); const path = require('path'); +const ProcessLauncher = require('../lib/processes/processLauncher'); describe('ProcessWrapper', () => { let processLauncher;