update to fix tests

This commit is contained in:
Iuri Matias 2018-07-26 12:37:33 -04:00
parent 69bb03d56d
commit a38428f762
7 changed files with 19 additions and 53 deletions

View File

@ -99,7 +99,7 @@ class Engine {
processManagerService(_options) { processManagerService(_options) {
const ProcessManager = require('../processes/processManager.js'); const ProcessManager = require('../processes/processManager.js');
const processManager = new ProcessManager({ this.processManager = new ProcessManager({
events: this.events, events: this.events,
logger: this.logger, logger: this.logger,
plugins: this.plugins plugins: this.plugins

View File

@ -6,7 +6,6 @@ const BlockchainProcessLauncher = require('./blockchainProcessLauncher');
class BlockchainModule { class BlockchainModule {
constructor(embark, options) { constructor(embark, options) {
const self = this;
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.blockchainConfig = embark.config.blockchainConfig; this.blockchainConfig = embark.config.blockchainConfig;
@ -41,14 +40,12 @@ class BlockchainModule {
cb = noLogs; cb = noLogs;
noLogs = false; noLogs = false;
} }
const NO_NODE_ERROR = Error("error connecting to blockchain node");
const self = this; const self = this;
async.waterfall([ async.waterfall([
// check if web3 is set // check if web3 is set
// //
function checkWeb3State(next) { function checkWeb3State(next) {
console.dir("checkWeb3State");
self.events.request("blockchain:web3:isReady", (connected) => { self.events.request("blockchain:web3:isReady", (connected) => {
console.dir("---> checking web3 state"); console.dir("---> checking web3 state");
console.dir(connected.toString()); console.dir(connected.toString());
@ -56,44 +53,20 @@ class BlockchainModule {
return next(connected); return next(connected);
} }
next(); 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) { function pingEndpoint(next) {
console.dir("pingEndpoint");
if (!self.contractsConfig || !self.contractsConfig.deployment || !self.contractsConfig.deployment.host) { if (!self.contractsConfig || !self.contractsConfig.deployment || !self.contractsConfig.deployment.host) {
return next(); return next();
} }
const {host, port, type, protocol} = self.contractsConfig.deployment; 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); utils.pingEndpoint(host, port, type, protocol, self.blockchainConfig.wsOrigins.split(',')[0], next);
} }
], function (err, result) { ], function (err, _result) {
console.dir("------");
console.dir(result);
console.dir("------");
if (err === true || err === undefined) { if (err === true || err === undefined) {
return cb(true); return cb(true);
} }
return cb(false); 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);
}); });
} }

View File

@ -8,7 +8,7 @@ const {canonicalHost} = require('../../utils/host');
let References = { let References = {
ipfs: 'https://ipfs.io/docs/install/', ipfs: 'https://ipfs.io/docs/install/',
swarm: 'http://swarm-guide.readthedocs.io/en/latest/installation.html' swarm: 'http://swarm-guide.readthedocs.io/en/latest/installation.html'
} };
class StorageProcessesLauncher { class StorageProcessesLauncher {
constructor(options) { constructor(options) {

View File

@ -8,29 +8,25 @@ class ProcessManager {
this.processes = {}; this.processes = {};
self.events.setCommandHandler('processes:register', (name, cb) => { self.events.setCommandHandler('processes:register', (name, cb) => {
console.dir("=====> registering " + name);
this.processes[name] = { this.processes[name] = {
state: 'unstarted', state: 'unstarted',
cb: cb cb: cb
} };
}); });
self.events.setCommandHandler('processes:launch', (name, cb) => { self.events.setCommandHandler('processes:launch', (name, cb) => {
let process = self.processes[name]; let process = self.processes[name];
// TODO: should make distinction between starting and running
if (process.state != 'unstarted') { if (process.state != 'unstarted') {
console.dir("=====> already started " + name); console.dir("=====> already started " + name);
return cb(); return cb();
} }
console.dir("=====> launching " + name);
process.state = 'starting'; process.state = 'starting';
//let pry = require('pryjs'); process.cb.apply(process.cb, [
//eval(pry.it); () => {
process.cb.apply(process.cb, [() => {
process.state = 'running'; process.state = 'running';
console.dir("=====> launched " + name);
cb(); cb();
}]); }
]);
}); });
} }

View File

@ -1,5 +1,5 @@
/*globals describe, it*/ /*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 constants = require('../lib/constants.json');
const {defaultHost} = require('../lib/utils/host'); const {defaultHost} = require('../lib/utils/host');

View File

@ -1,6 +1,6 @@
/*globals describe, it*/ /*globals describe, it*/
let ContractsManager = require('../lib/contracts/contracts.js'); 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 Logger = require('../lib/core/logger.js');
let File = require('../lib/core/file.js'); let File = require('../lib/core/file.js');
let TestLogger = require('../lib/tests/test_logger.js'); let TestLogger = require('../lib/tests/test_logger.js');
@ -37,11 +37,11 @@ describe('embark.Contracts', function() {
}); });
plugins.loadInternalPlugin('solidity', {ipc: ipcObject}); plugins.loadInternalPlugin('solidity', {ipc: ipcObject});
let compiler = new Compiler({plugins: plugins, logger: plugins.logger});
let events = new Events(); let events = new Events();
events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins});
compiler.compile_contracts(contractFiles, cb); //events.setCommandHandler("compiler:contracts", function(contractFiles, cb) {
}); // compiler.compile_contracts(contractFiles, cb);
//});
events.setCommandHandler("config:contractsConfig", function(cb) { events.setCommandHandler("config:contractsConfig", function(cb) {
cb(contractsConfig); cb(contractsConfig);
@ -146,11 +146,8 @@ describe('embark.Contracts', function() {
}); });
plugins.loadInternalPlugin('solidity', {ipc: ipcObject}); plugins.loadInternalPlugin('solidity', {ipc: ipcObject});
let compiler = new Compiler({plugins: plugins, logger: plugins.logger});
let events = new Events(); let events = new Events();
events.setCommandHandler("compiler:contracts", function(contractFiles, cb) { let compiler = new Compiler({events: events, logger: plugins.logger}, {plugins: plugins});
compiler.compile_contracts(contractFiles, cb);
});
events.setCommandHandler("config:contractsConfig", function(cb) { events.setCommandHandler("config:contractsConfig", function(cb) {
cb(contractsConfig); cb(contractsConfig);

View File

@ -2,8 +2,8 @@
const assert = require('assert'); const assert = require('assert');
const sinon = require('sinon'); const sinon = require('sinon');
const TestLogger = require('../lib/tests/test_logger'); const TestLogger = require('../lib/tests/test_logger');
const ProcessLauncher = require('../lib/process/processLauncher');
const path = require('path'); const path = require('path');
const ProcessLauncher = require('../lib/processes/processLauncher');
describe('ProcessWrapper', () => { describe('ProcessWrapper', () => {
let processLauncher; let processLauncher;