Merge pull request #661 from embark-framework/modules_refactor_2
Modules refactor p2
This commit is contained in:
commit
6f2a2aba8d
|
@ -1,6 +1,6 @@
|
|||
const program = require('commander');
|
||||
const Embark = require('../lib/index');
|
||||
const i18n = require('./i18n/i18n.js');
|
||||
const i18n = require('./core/i18n/i18n.js');
|
||||
let embark = new Embark;
|
||||
|
||||
class Cmd {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
var fs = require('../core/fs.js');
|
||||
|
||||
module.exports = function() {
|
||||
fs.removeSync('./chains.json');
|
||||
fs.removeSync('.embark/');
|
||||
fs.removeSync('dist/');
|
||||
console.log(__("reset done!").green);
|
||||
};
|
|
@ -33,36 +33,10 @@ class Engine {
|
|||
this.isDev = this.config && this.config.blockchainConfig && (this.config.blockchainConfig.isDev || this.config.blockchainConfig.default);
|
||||
|
||||
if (this.interceptLogs || this.interceptLogs === undefined) {
|
||||
this.doInterceptLogs();
|
||||
utils.interceptLogs(console, this.logger);
|
||||
}
|
||||
}
|
||||
|
||||
doInterceptLogs() {
|
||||
var self = this;
|
||||
let context = {};
|
||||
context.console = console;
|
||||
|
||||
context.console.log = function() {
|
||||
self.logger.info(utils.normalizeInput(arguments));
|
||||
};
|
||||
context.console.warn = function() {
|
||||
self.logger.warn(utils.normalizeInput(arguments));
|
||||
};
|
||||
context.console.info = function() {
|
||||
self.logger.info(utils.normalizeInput(arguments));
|
||||
};
|
||||
context.console.debug = function() {
|
||||
// TODO: ue JSON.stringify
|
||||
self.logger.debug(utils.normalizeInput(arguments));
|
||||
};
|
||||
context.console.trace = function() {
|
||||
self.logger.trace(utils.normalizeInput(arguments));
|
||||
};
|
||||
context.console.dir = function() {
|
||||
self.logger.dir(utils.normalizeInput(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
registerModule(moduleName, options) {
|
||||
this.plugins.loadInternalPlugin(moduleName, options || {});
|
||||
}
|
||||
|
@ -98,7 +72,7 @@ class Engine {
|
|||
}
|
||||
|
||||
processManagerService(_options) {
|
||||
const ProcessManager = require('../processes/processManager.js');
|
||||
const ProcessManager = require('./processes/processManager.js');
|
||||
this.processManager = new ProcessManager({
|
||||
events: this.events,
|
||||
logger: this.logger,
|
||||
|
@ -158,21 +132,10 @@ class Engine {
|
|||
codeGeneratorService(_options) {
|
||||
let self = this;
|
||||
|
||||
const CodeGenerator = require('../contracts/code_generator.js');
|
||||
this.codeGenerator = new CodeGenerator({
|
||||
blockchainConfig: self.config.blockchainConfig,
|
||||
contractsConfig: self.config.contractsConfig,
|
||||
plugins: self.plugins,
|
||||
storageConfig: self.config.storageConfig,
|
||||
namesystemConfig: self.config.namesystemConfig,
|
||||
communicationConfig: self.config.communicationConfig,
|
||||
events: self.events,
|
||||
env: self.env
|
||||
});
|
||||
this.codeGenerator.listenToCommands();
|
||||
this.registerModule('code_generator', {plugins: self.plugins, env: self.env});
|
||||
|
||||
const generateCode = function () {
|
||||
self.codeGenerator.buildEmbarkJS(function() {
|
||||
self.events.request("code-generator:embarkjs:build", () => {
|
||||
self.events.emit('code-generator-ready');
|
||||
});
|
||||
};
|
||||
|
@ -206,6 +169,7 @@ class Engine {
|
|||
this.registerModule('specialconfigs');
|
||||
this.registerModule('console_listener', {ipc: this.ipc});
|
||||
|
||||
// TODO: need to refactor dependencies before moving into a module
|
||||
const ContractsManager = require('../contracts/contracts.js');
|
||||
this.contractsManager = new ContractsManager({
|
||||
contractFiles: this.config.contractsFiles,
|
||||
|
@ -216,23 +180,7 @@ class Engine {
|
|||
events: this.events
|
||||
});
|
||||
|
||||
const DeployManager = require('../contracts/deploy_manager.js');
|
||||
this.deployManager = new DeployManager({
|
||||
blockchain: this.blockchain,
|
||||
config: this.config,
|
||||
logger: this.logger,
|
||||
plugins: this.plugins,
|
||||
events: this.events,
|
||||
onlyCompile: options.onlyCompile
|
||||
});
|
||||
|
||||
const ContractDeployer = require('../contracts/contract_deployer.js');
|
||||
this.contractDeployer = new ContractDeployer({
|
||||
blockchain: this.blockchain,
|
||||
logger: this.logger,
|
||||
events: this.events,
|
||||
plugins: this.plugins
|
||||
});
|
||||
this.registerModule('deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
|
||||
|
||||
this.events.on('file-event', function (fileType) {
|
||||
clearTimeout(self.fileTimeout);
|
||||
|
@ -277,30 +225,16 @@ class Engine {
|
|||
isDev: this.isDev
|
||||
});
|
||||
|
||||
const Blockchain = require('../contracts/blockchain.js');
|
||||
this.blockchain = new Blockchain({
|
||||
contractsConfig: this.config.contractsConfig,
|
||||
blockchainConfig: this.config.blockchainConfig,
|
||||
events: this.events,
|
||||
logger: this.logger,
|
||||
this.registerModule('blockchain_connector', {
|
||||
isDev: this.isDev,
|
||||
locale: this.locale,
|
||||
web3: options.web3
|
||||
});
|
||||
|
||||
this.registerModule('whisper', {
|
||||
// TODO: this should not be needed and should be deducted from the config instead
|
||||
// the eth provider is not necessary the same as the whisper one
|
||||
web3: this.blockchain.web3
|
||||
});
|
||||
this.registerModule('whisper');
|
||||
}
|
||||
|
||||
libraryManagerService(_options) {
|
||||
const LibraryManager = require('../versions/library_manager.js');
|
||||
this.libraryManager = new LibraryManager({
|
||||
plugins: this.plugins,
|
||||
config: this.config
|
||||
});
|
||||
this.registerModule('library_manager');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ i18n.configure({
|
|||
locales: supported_languages,
|
||||
register: global,
|
||||
updateFiles: false,
|
||||
directory: path.join(__dirname, 'locales')
|
||||
directory: path.join(__dirname, '../../../', 'locales')
|
||||
});
|
||||
|
||||
function isSupported(locale) {
|
|
@ -1,5 +1,5 @@
|
|||
const uuid = require('uuid/v1');
|
||||
const constants = require('../constants');
|
||||
const constants = require('../../constants');
|
||||
|
||||
class Events {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
const child_process = require('child_process');
|
||||
const constants = require('../constants');
|
||||
const constants = require('../../constants');
|
||||
const path = require('path');
|
||||
const utils = require('../utils/utils');
|
||||
const utils = require('../../utils/utils');
|
||||
|
||||
class ProcessLauncher {
|
||||
|
|
@ -17,7 +17,6 @@ class ProcessManager {
|
|||
self.events.setCommandHandler('processes:launch', (name, cb) => {
|
||||
let process = self.processes[name];
|
||||
if (process.state != 'unstarted') {
|
||||
console.dir("=====> already started " + name);
|
||||
return cb();
|
||||
}
|
||||
process.state = 'starting';
|
|
@ -1,4 +1,4 @@
|
|||
const constants = require('../constants');
|
||||
const constants = require('../../constants');
|
||||
const Events = require('./eventsWrapper');
|
||||
|
||||
// Override process.chdir so that we have a partial-implementation PWD for Windows
|
|
@ -354,9 +354,11 @@ class Embark {
|
|||
}
|
||||
|
||||
reset() {
|
||||
this.context = [constants.contexts.reset];
|
||||
let resetCmd = require('./cmds/reset.js');
|
||||
resetCmd();
|
||||
var fs = require('../core/fs.js');
|
||||
fs.removeSync('./chains.json');
|
||||
fs.removeSync('.embark/');
|
||||
fs.removeSync('dist/');
|
||||
console.log(__("reset done!").green);
|
||||
}
|
||||
|
||||
upload(options) {
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
const Web3 = require('web3');
|
||||
const async = require('async');
|
||||
const Provider = require('./provider.js');
|
||||
const utils = require('../utils/utils');
|
||||
const utils = require('../../utils/utils');
|
||||
|
||||
const WEB3_READY = 'web3Ready';
|
||||
|
||||
// TODO: consider another name, this is the blockchain connector
|
||||
class Blockchain {
|
||||
constructor(options) {
|
||||
class BlockchainConnector {
|
||||
constructor(embark, options) {
|
||||
const self = this;
|
||||
this.plugins = options.plugins;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.contractsConfig = options.contractsConfig;
|
||||
this.blockchainConfig = options.blockchainConfig;
|
||||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.contractsConfig = embark.config.contractsConfig;
|
||||
this.blockchainConfig = embark.config.blockchainConfig;
|
||||
this.web3 = options.web3;
|
||||
this.isDev = options.isDev;
|
||||
this.web3Endpoint = '';
|
||||
|
@ -24,6 +24,10 @@ class Blockchain {
|
|||
cb(self.isWeb3Ready);
|
||||
});
|
||||
|
||||
self.events.setCommandHandler("blockchain:object", (cb) => {
|
||||
cb(self);
|
||||
});
|
||||
|
||||
if (!this.web3) {
|
||||
this.initWeb3();
|
||||
} else {
|
||||
|
@ -277,5 +281,5 @@ class Blockchain {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Blockchain;
|
||||
module.exports = BlockchainConnector;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
const async = require('async');
|
||||
const AccountParser = require('./accountParser');
|
||||
const AccountParser = require('../../utils/accountParser');
|
||||
const fundAccount = require('./fundAccount');
|
||||
|
||||
class Provider {
|
|
@ -1,6 +1,6 @@
|
|||
const ProcessWrapper = require('../../processes/processWrapper');
|
||||
const ProcessWrapper = require('../../core/processes/processWrapper');
|
||||
const BlockchainClient = require('./blockchain');
|
||||
const i18n = require('../../i18n/i18n.js');
|
||||
const i18n = require('../../core/i18n/i18n.js');
|
||||
const constants = require('../../constants');
|
||||
|
||||
let blockchainProcess;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const ProcessLauncher = require('../../processes/processLauncher');
|
||||
const ProcessLauncher = require('../../core/processes/processLauncher');
|
||||
const utils = require('../../utils/utils.js');
|
||||
const constants = require('../../constants');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let async = require('async');
|
||||
let fs = require('../core/fs.js');
|
||||
const utils = require('../utils/utils.js');
|
||||
let fs = require('../../core/fs.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
|
||||
require('ejs');
|
||||
const Templates = {
|
||||
|
@ -19,17 +19,24 @@ const Templates = {
|
|||
};
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(options) {
|
||||
this.blockchainConfig = options.blockchainConfig || {};
|
||||
constructor(embark, options) {
|
||||
this.blockchainConfig = embark.config.blockchainConfig || {};
|
||||
this.rpcHost = this.blockchainConfig.rpcHost || '';
|
||||
this.rpcPort = this.blockchainConfig.rpcPort || '';
|
||||
this.contractsConfig = options.contractsConfig || {};
|
||||
this.storageConfig = options.storageConfig || {};
|
||||
this.communicationConfig = options.communicationConfig || {};
|
||||
this.namesystemConfig = options.namesystemConfig || {};
|
||||
this.contractsConfig = embark.config.contractsConfig || {};
|
||||
this.storageConfig = embark.config.storageConfig || {};
|
||||
this.communicationConfig = embark.config.communicationConfig || {};
|
||||
this.namesystemConfig = embark.config.namesystemConfig || {};
|
||||
this.env = options.env || 'development';
|
||||
this.plugins = options.plugins;
|
||||
this.events = options.events;
|
||||
this.events = embark.events;
|
||||
|
||||
this.listenToCommands();
|
||||
|
||||
const self = this;
|
||||
this.events.setCommandHandler("code-generator:embarkjs:build", (cb) => {
|
||||
self.buildEmbarkJS(cb);
|
||||
});
|
||||
}
|
||||
|
||||
listenToCommands() {
|
|
@ -1,16 +1,14 @@
|
|||
let async = require('async');
|
||||
//require("../utils/debug_util.js")(__filename, async);
|
||||
let utils = require('../utils/utils.js');
|
||||
let utils = require('../../utils/utils.js');
|
||||
|
||||
class ContractDeployer {
|
||||
constructor(options) {
|
||||
const self = this;
|
||||
|
||||
this.blockchain = options.blockchain;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.plugins = options.plugins;
|
||||
this.gasLimit = options.gasLimit;
|
||||
|
||||
self.events.setCommandHandler('deploy:contract', (contract, cb) => {
|
||||
self.checkAndDeployContract(contract, null, cb);
|
||||
|
@ -72,6 +70,13 @@ class ContractDeployer {
|
|||
}
|
||||
|
||||
async.waterfall([
|
||||
function requestBlockchainConnector(callback) {
|
||||
self.events.request("blockchain:object", (blockchain) => {
|
||||
self.blockchain = blockchain;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
function _determineArguments(next) {
|
||||
self.determineArguments(params || contract.args, contract, (err, realArgs) => {
|
||||
if (err) {
|
|
@ -1,16 +1,17 @@
|
|||
let async = require('async');
|
||||
|
||||
const utils = require('../utils/utils.js');
|
||||
const ContractDeployer = require('./contract_deployer.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
//require("../utils/debug_util.js")(__filename, async);
|
||||
|
||||
class DeployManager {
|
||||
constructor(options) {
|
||||
constructor(embark, options) {
|
||||
const self = this;
|
||||
this.config = options.config;
|
||||
this.logger = options.logger;
|
||||
this.config = embark.config;
|
||||
this.logger = embark.logger;
|
||||
this.blockchainConfig = this.config.blockchainConfig;
|
||||
|
||||
this.events = options.events;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
this.blockchain = options.blockchain;
|
||||
this.gasLimit = false;
|
||||
|
@ -18,9 +19,25 @@ class DeployManager {
|
|||
this.deployOnlyOnConfig = false;
|
||||
this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false;
|
||||
|
||||
this.contractDeployer = new ContractDeployer({
|
||||
logger: this.logger,
|
||||
events: this.events,
|
||||
plugins: this.plugins
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('deploy:setGasLimit', (gasLimit) => {
|
||||
self.gasLimit = gasLimit;
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('deploy:contracts', (cb) => {
|
||||
self.deployContracts(cb);
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('deploy:contracts:test', (cb) => {
|
||||
self.fatalErrors = true;
|
||||
self.deployOnlyOnConfig = true;
|
||||
self.deployContracts(cb);
|
||||
});
|
||||
}
|
||||
|
||||
deployAll(done) {
|
||||
|
@ -71,6 +88,13 @@ class DeployManager {
|
|||
}
|
||||
|
||||
async.waterfall([
|
||||
function requestBlockchainConnector(callback) {
|
||||
self.events.request("blockchain:object", (blockchain) => {
|
||||
self.blockchain = blockchain;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
|
||||
function buildContracts(callback) {
|
||||
self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => {
|
||||
callback(err);
|
|
@ -1,5 +1,5 @@
|
|||
const child_process = require('child_process');
|
||||
const ProcessWrapper = require('../../processes/processWrapper');
|
||||
const ProcessWrapper = require('../../core/processes/processWrapper');
|
||||
const constants = require('../../constants');
|
||||
|
||||
let ipfsProcess; // eslint-disable-line no-unused-vars
|
||||
|
|
|
@ -2,14 +2,12 @@ var Npm = require('./npm.js');
|
|||
|
||||
class LibraryManager {
|
||||
|
||||
constructor(options) {
|
||||
this.plugins = options.plugins;
|
||||
this.config = options.config;
|
||||
constructor(embark) {
|
||||
this.embark = embark;
|
||||
this.config = embark.config;
|
||||
this.contractsConfig = this.config.contractsConfig;
|
||||
this.storageConfig = this.config.storageConfig;
|
||||
|
||||
this.embark = this.plugins.createPlugin('libraryManager', {});
|
||||
|
||||
this.determineVersions();
|
||||
|
||||
this.registerCommands();
|
|
@ -1,7 +1,7 @@
|
|||
const fs = require('../core/fs.js');
|
||||
const fs = require('../../core/fs.js');
|
||||
const PluginManager = require('live-plugin-manager-git-fix').PluginManager;
|
||||
require('colors');
|
||||
const NpmTimer = require('./npmTimer');
|
||||
const NpmTimer = require('./npmTimer.js');
|
||||
|
||||
class Npm {
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
const {PerformanceObserver, performance} = require('perf_hooks');
|
||||
require('colors');
|
||||
const utils = require('../utils/utils.js');
|
||||
const i18n = require('../i18n/i18n.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
const i18n = require('../../core/i18n/i18n.js');
|
||||
i18n.setOrDetectLocale('en');
|
||||
|
||||
|
||||
class NpmTimer{
|
||||
constructor(options){
|
||||
this._logger = (options.logger && typeof options.logger.info == 'function') ? options.logger : console;
|
||||
|
@ -13,17 +12,15 @@ class NpmTimer{
|
|||
this._showSpinner = options.showSpinner || false;
|
||||
this._spinnerStyle = options.spinnerStyle || 'dots';
|
||||
this._interval = options.interval || 750;
|
||||
|
||||
|
||||
// define mark and measurement names
|
||||
this._startMark = 'downloadStart' + this._packageName + this._version;
|
||||
this._ongoingMark = 'downloadOngoingMark' + this._packageName + this._version;
|
||||
this._downloadOngoing = 'downloadOngoing' + this._packageName + this._version;
|
||||
this._endMark = 'downloadEnd' + this._packageName + this._version;
|
||||
this._downloadComplete = 'downloadComplete' + this._packageName + this._version;
|
||||
|
||||
this.observer.observe({entryTypes: ['measure']});
|
||||
|
||||
|
||||
this.observer.observe({entryTypes: ['measure']});
|
||||
}
|
||||
|
||||
get observer(){
|
||||
|
@ -31,7 +28,7 @@ class NpmTimer{
|
|||
this._observer = new PerformanceObserver((items) => {
|
||||
let entry;
|
||||
let strDuration;
|
||||
|
||||
|
||||
// find any download ongoing measurements we've made
|
||||
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadOngoing));
|
||||
if(entry){
|
||||
|
@ -42,14 +39,13 @@ class NpmTimer{
|
|||
else{
|
||||
// otherwise, find our download complete measurement
|
||||
entry = utils.last(items.getEntries().filter(entry => entry.name === this._downloadComplete));
|
||||
|
||||
if(entry){
|
||||
strDuration = __('Finished downloading and installing {{packageName}} {{version}} in {{duration}}ms', {packageName: this._packageName, version: this._version, duration: entry.duration});
|
||||
performance.clearMarks();
|
||||
if(this._spinner) this._spinner.succeed(strDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// log our measurement and make it red if it has taken too long
|
||||
if(!this._showSpinner && entry && strDuration){
|
||||
if(entry.duration > 4000){
|
||||
|
@ -57,12 +53,12 @@ class NpmTimer{
|
|||
}
|
||||
this._logger.info(strDuration);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
return this._observer;
|
||||
}
|
||||
|
||||
|
||||
start(){
|
||||
let self = this;
|
||||
|
||||
|
@ -79,7 +75,7 @@ class NpmTimer{
|
|||
|
||||
// mark our start time
|
||||
performance.mark(this._startMark);
|
||||
|
||||
|
||||
// function that continually updates the console to show user that we're downloading a library
|
||||
this._intOngoingDownload = setInterval(
|
||||
function(){
|
|
@ -2,9 +2,9 @@ const fs = require('fs-extra');
|
|||
const path = require('path');
|
||||
const constants = require('../../constants');
|
||||
const Utils = require('../../utils/utils');
|
||||
const ProcessWrapper = require('../../processes/processWrapper');
|
||||
const ProcessWrapper = require('../../core/processes/processWrapper');
|
||||
const PluginManager = require('live-plugin-manager-git-fix').PluginManager;
|
||||
const NpmTimer = require('../../versions/npmTimer');
|
||||
const NpmTimer = require('../library_manager/npmTimer');
|
||||
|
||||
|
||||
class SolcProcess extends ProcessWrapper {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let utils = require('../../utils/utils.js');
|
||||
let fs = require('../../core/fs.js');
|
||||
let currentSolcVersion = require('../../../package.json').dependencies.solc;
|
||||
const ProcessLauncher = require('../../processes/processLauncher');
|
||||
const ProcessLauncher = require('../../core/processes/processLauncher.js');
|
||||
const uuid = require('uuid/v1');
|
||||
|
||||
class SolcW {
|
||||
|
@ -38,7 +38,8 @@ class SolcW {
|
|||
this.solcProcess = new ProcessLauncher({
|
||||
modulePath: utils.joinPath(__dirname, 'solcP.js'),
|
||||
logger: self.logger,
|
||||
events: self.events
|
||||
events: self.events,
|
||||
silent: false
|
||||
});
|
||||
|
||||
this.solcProcess.once("result", "initiated", () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const fs = require('../../core/fs');
|
||||
const shellJs = require('shelljs');
|
||||
const utils = require('../../utils/utils');
|
||||
const ProcessLauncher = require('../../processes/processLauncher');
|
||||
const ProcessLauncher = require('../../core/processes/processLauncher');
|
||||
const constants = require('../../constants');
|
||||
const {canonicalHost} = require('../../utils/host');
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const child_process = require('child_process');
|
||||
const ProcessWrapper = require('../../processes/processWrapper');
|
||||
const ProcessWrapper = require('../../core/processes/processWrapper');
|
||||
const constants = require('../../constants');
|
||||
const fs = require('../../core/fs');
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const fs = require('../core/fs.js');
|
||||
const async = require('async');
|
||||
const ProcessLauncher = require('../processes/processLauncher');
|
||||
const ProcessLauncher = require('../core/processes/processLauncher');
|
||||
const utils = require('../utils/utils.js');
|
||||
const constants = require('../constants');
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ const utils = require('../utils/utils');
|
|||
const fs = require('../core/fs');
|
||||
const constants = require('../constants');
|
||||
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
||||
const ProcessWrapper = require('../processes/processWrapper');
|
||||
const ProcessWrapper = require('../core/processes/processWrapper');
|
||||
const path = require('path');
|
||||
|
||||
let webpackProcess;
|
||||
|
|
|
@ -104,7 +104,7 @@ module.exports = {
|
|||
mocha.reporter(EmbarkSpec, {
|
||||
events: global.embark.engine.events,
|
||||
gasDetails: options.gasDetails,
|
||||
gasLimit: global.embark.engine.deployManager.gasLimit
|
||||
gasLimit: 6000000
|
||||
});
|
||||
mocha.addFile(file);
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ const Web3 = require('web3');
|
|||
const constants = require('../constants');
|
||||
const Events = require('../core/events');
|
||||
const cloneDeep = require('clone-deep');
|
||||
const AccountParser = require('../contracts/accountParser');
|
||||
const Provider = require('../contracts/provider');
|
||||
const AccountParser = require('../utils/accountParser');
|
||||
// TODO: breaks module isolation; tests need to be refactored to use the engine and avoid this
|
||||
const Provider = require('../modules/blockchain_connector/provider.js');
|
||||
const utils = require('../utils/utils');
|
||||
|
||||
const EmbarkJS = require('embarkjs');
|
||||
|
@ -119,8 +120,7 @@ class Test {
|
|||
trackContracts: false
|
||||
//ipcRole: 'client' // disabled for now due to issues with ipc file
|
||||
});
|
||||
this.engine.deployManager.gasLimit = 6000000;
|
||||
this.engine.contractsManager.gasLimit = 6000000;
|
||||
this.events.request('deploy:setGasLimit', 6000000);
|
||||
}
|
||||
|
||||
init(callback) {
|
||||
|
@ -305,9 +305,7 @@ class Test {
|
|||
});
|
||||
},
|
||||
function deploy(accounts, next) {
|
||||
self.engine.deployManager.fatalErrors = true;
|
||||
self.engine.deployManager.deployOnlyOnConfig = true;
|
||||
self.engine.events.request('deploy:contracts', () => {
|
||||
self.engine.events.request('deploy:contracts:test', () => {
|
||||
next(null, accounts);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -342,6 +342,31 @@ function last(array) {
|
|||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
function interceptLogs(consoleContext, logger) {
|
||||
let context = {};
|
||||
context.console = consoleContext;
|
||||
|
||||
context.console.log = function() {
|
||||
logger.info(normalizeInput(arguments));
|
||||
};
|
||||
context.console.warn = function() {
|
||||
logger.warn(normalizeInput(arguments));
|
||||
};
|
||||
context.console.info = function() {
|
||||
logger.info(normalizeInput(arguments));
|
||||
};
|
||||
context.console.debug = function() {
|
||||
// TODO: ue JSON.stringify
|
||||
logger.debug(normalizeInput(arguments));
|
||||
};
|
||||
context.console.trace = function() {
|
||||
logger.trace(normalizeInput(arguments));
|
||||
};
|
||||
context.console.dir = function() {
|
||||
logger.dir(normalizeInput(arguments));
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
joinPath,
|
||||
dirname,
|
||||
|
@ -376,5 +401,6 @@ module.exports = {
|
|||
compact,
|
||||
groupBy,
|
||||
sample,
|
||||
last
|
||||
last,
|
||||
interceptLogs
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*global describe, it*/
|
||||
const assert = require('assert');
|
||||
const sinon = require('sinon');
|
||||
const AccountParser = require('../lib/contracts/accountParser');
|
||||
const AccountParser = require('../lib/utils/accountParser');
|
||||
let TestLogger = require('../lib/tests/test_logger.js');
|
||||
const Web3 = require('web3');
|
||||
const i18n = require('../lib/i18n/i18n.js');
|
||||
const i18n = require('../lib/core/i18n/i18n.js');
|
||||
i18n.setOrDetectLocale('en');
|
||||
|
||||
describe('embark.AccountParser', function () {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*globals describe, it*/
|
||||
let CodeGenerator = require('../lib/contracts/code_generator.js');
|
||||
let CodeGenerator = require('../lib/modules/code_generator');
|
||||
let assert = require('assert');
|
||||
|
||||
function replaceCRLF(string) {
|
||||
|
@ -29,7 +29,14 @@ describe('embark.CodeGenerator', function() {
|
|||
}
|
||||
]
|
||||
|
||||
let generator = new CodeGenerator({blockchainConfig: {}});
|
||||
const TestEvents = {
|
||||
request: (cmd, cb) => {
|
||||
cb(currentSolcVersion);
|
||||
},
|
||||
setCommandHandler: () => {
|
||||
}
|
||||
};
|
||||
let generator = new CodeGenerator({config: {blockchainConfig: {}}, events: TestEvents}, {});
|
||||
|
||||
describe('with EmbarkJS', function() {
|
||||
let withEmbarkJS = true;
|
||||
|
|
|
@ -3,7 +3,7 @@ const assert = require('assert');
|
|||
const sinon = require('sinon');
|
||||
const TestLogger = require('../lib/tests/test_logger');
|
||||
const path = require('path');
|
||||
const ProcessLauncher = require('../lib/processes/processLauncher');
|
||||
const ProcessLauncher = require('../lib/core/processes/processLauncher');
|
||||
|
||||
describe('ProcessWrapper', () => {
|
||||
let processLauncher;
|
||||
|
|
Loading…
Reference in New Issue