mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-14 01:05:03 +00:00
make tests work by using events
This commit is contained in:
parent
ca3aea7923
commit
ddc8b36329
@ -537,16 +537,14 @@ class EmbarkController {
|
||||
client: options.client,
|
||||
locale: options.locale,
|
||||
version: this.version,
|
||||
embarkConfig: 'embark.json',
|
||||
interceptLogs: false,
|
||||
embarkConfig: options.embarkConfig || 'embark.json',
|
||||
logFile: options.logFile,
|
||||
logLevel: options.logLevel,
|
||||
events: options.events,
|
||||
logger: options.logger,
|
||||
config: options.config,
|
||||
plugins: options.plugins,
|
||||
context: this.context,
|
||||
webpackConfigName: options.webpackConfigName
|
||||
useDashboard: options.useDashboard,
|
||||
webpackConfigName: options.webpackConfigName,
|
||||
ipcRole: 'client',
|
||||
interceptLogs: false
|
||||
});
|
||||
|
||||
async.waterfall([
|
||||
@ -555,8 +553,10 @@ class EmbarkController {
|
||||
},
|
||||
function startServices(callback) {
|
||||
engine.startService("processManager");
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("web3", {wait: true}); // Empty web3 as Test changes it
|
||||
engine.startService("deployment");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("testRunner");
|
||||
callback();
|
||||
},
|
||||
|
@ -13,7 +13,7 @@ const unitRegex = /([0-9]+) ([a-zA-Z]+)/;
|
||||
|
||||
var Config = function(options) {
|
||||
const self = this;
|
||||
this.env = options.env;
|
||||
this.env = options.env || 'default';
|
||||
this.blockchainConfig = {};
|
||||
this.contractsConfig = {};
|
||||
this.pipelineConfig = {};
|
||||
|
@ -67,9 +67,11 @@ class BlockchainConnector {
|
||||
}
|
||||
|
||||
if (type === 'vm') {
|
||||
this.provider = this._getSimulator().provider;
|
||||
this.web3.setProvider(this.provider(this.contractsConfig.deployment));
|
||||
return self._emitWeb3Ready();
|
||||
const sim = this._getSimulator();
|
||||
this.provider = sim.provider(this.contractsConfig.deployment);
|
||||
this.web3.setProvider(this.provider);
|
||||
this._emitWeb3Ready();
|
||||
return cb();
|
||||
}
|
||||
|
||||
protocol = (type === "rpc") ? protocol : 'ws';
|
||||
|
@ -55,7 +55,6 @@ class Solidity {
|
||||
|
||||
self.logger.info(__("loading solc compiler") + "..");
|
||||
self.solcW.load_compiler(function (err) {
|
||||
console.log('LOADED');
|
||||
self.solcAlreadyLoaded = true;
|
||||
callback(err);
|
||||
});
|
||||
@ -147,7 +146,6 @@ class Solidity {
|
||||
callback(null, compiled_object);
|
||||
}
|
||||
], function (err, result) {
|
||||
console.log('COMPLETED COMPILATION', err);
|
||||
cb(err, result);
|
||||
});
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ const NpmTimer = require('../library_manager/npmTimer');
|
||||
class SolcProcess extends ProcessWrapper {
|
||||
|
||||
constructor(options){
|
||||
console.error('ALLO');
|
||||
super({pingParent: false});
|
||||
this._logger = options.logger;
|
||||
this._showSpinner = options.showSpinner === true;
|
||||
@ -67,7 +66,6 @@ class SolcProcess extends ProcessWrapper {
|
||||
|
||||
let solcProcess;
|
||||
process.on('message', (msg) => {
|
||||
console.error('MSG', msg.action);
|
||||
if (msg.action === "init") {
|
||||
solcProcess = new SolcProcess(msg.options);
|
||||
return process.send({result: "initiated"});
|
||||
|
@ -45,7 +45,6 @@ class SolcW {
|
||||
events: self.events,
|
||||
silent: false
|
||||
});
|
||||
console.log(utils.joinPath(__dirname, 'solcP.js'));
|
||||
|
||||
this.solcProcess.once("result", "initiated", () => {
|
||||
this.events.request("version:get:solc", function(solcVersion) {
|
||||
|
@ -64,7 +64,7 @@ class TestRunner {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
console.log(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`);
|
||||
self.logger.info(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`);
|
||||
const opn = require('opn');
|
||||
const _next = () => { next(null, results); };
|
||||
if (options.noBrowser) {
|
||||
@ -78,14 +78,14 @@ class TestRunner {
|
||||
}
|
||||
], (err, results) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
self.logger.error(err);
|
||||
return cb(err);
|
||||
}
|
||||
let totalFailures = results.reduce((acc, result) => acc + result.failures, 0);
|
||||
if (totalFailures) {
|
||||
return cb(` > Total number of failures: ${totalFailures}`.red.bold);
|
||||
}
|
||||
console.log(' > All tests passed'.green.bold);
|
||||
self.logger.info(' > All tests passed'.green.bold);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
@ -131,8 +131,8 @@ class TestRunner {
|
||||
global.config = test.config.bind(test);
|
||||
|
||||
let deprecatedWarning = function () {
|
||||
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
||||
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
||||
self.logger.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
||||
self.logger.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
||||
process.exit();
|
||||
};
|
||||
|
||||
@ -199,7 +199,7 @@ class TestRunner {
|
||||
}
|
||||
|
||||
runSolidityTests(files, options, cb) {
|
||||
console.log('Running solc tests');
|
||||
self.logger.info('Running solc tests');
|
||||
const loglevel = options.loglevel || 'warn';
|
||||
let solcTest = new SolcTest({loglevel, node: options.node});
|
||||
global.embark = solcTest;
|
||||
|
@ -101,6 +101,7 @@ class Test {
|
||||
this.configObj.contractsConfig.deployment = this.simOptions;
|
||||
this.blockchainConnector.contractsConfig = this.configObj.contractsConfig;
|
||||
this.blockchainConnector.isWeb3Ready = false;
|
||||
this.blockchainConnector.wait = false;
|
||||
|
||||
// TODO change this
|
||||
if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
|
||||
@ -123,11 +124,11 @@ class Test {
|
||||
isDev: false,
|
||||
web3Endpoint: endpoint
|
||||
};
|
||||
console.info(`Connecting to node at ${endpoint}`.cyan);
|
||||
self.logger.info(`Connecting to node at ${endpoint}`.cyan);
|
||||
|
||||
return utils.pingEndpoint(host, port, type, protocol, this.configObj.blockchainConfig.wsOrigins.split(',')[0], (err) => {
|
||||
if (err) {
|
||||
console.error(`Error connecting to the node, there might be an error in ${endpoint}`.red);
|
||||
self.logger.error(`Error connecting to the node, there might be an error in ${endpoint}`.red);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@ -303,6 +304,12 @@ class Test {
|
||||
function checkDeploymentOpts(next) {
|
||||
self.checkDeploymentOptions(options, next);
|
||||
},
|
||||
function updateWeb3(next) {
|
||||
self.events.request("blockchain:get", function(web3) {
|
||||
self.web3 = web3;
|
||||
next();
|
||||
});
|
||||
},
|
||||
function compileContracts(next) {
|
||||
if (!self.firstDeployment) {
|
||||
return next();
|
||||
@ -407,7 +414,8 @@ class Test {
|
||||
}
|
||||
], function (err, accounts) {
|
||||
if (err) {
|
||||
self.logger.log(__('terminating due to error'));
|
||||
self.logger.error(__('terminating due to error'));
|
||||
self.logger.error(err.message || err);
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, accounts);
|
||||
|
Loading…
x
Reference in New Issue
Block a user