mirror of https://github.com/embarklabs/embark.git
fix tests
This commit is contained in:
parent
4e026fb6e7
commit
e8db6dc8a0
|
@ -2,15 +2,12 @@
|
|||
"contracts": ["app/contracts/**"],
|
||||
"app": {
|
||||
"css/app.css": ["app/css/**"],
|
||||
"images/": ["app/images/**"],
|
||||
"js/app.js": ["embark.js", "app/js/_vendor/jquery.min.js", "app/js/_vendor/bootstrap.min.js", "app/js/**"],
|
||||
"index.html": "app/index.html"
|
||||
},
|
||||
"buildDir": "dist/",
|
||||
"config": "config/",
|
||||
"plugins": {
|
||||
"embark-pipelinefiles": {},
|
||||
"embark-pipelinefiles2": {},
|
||||
"embark-babel": {},
|
||||
"embark-contracts": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
"homepage": "",
|
||||
"devDependencies": {
|
||||
"embark": "^2.2.1",
|
||||
"mocha": "^3.2.0"
|
||||
"mocha": "^2.2.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ var Plugins = require('./plugins.js');
|
|||
var ABIGenerator = function(options) {
|
||||
this.blockchainConfig = options.blockchainConfig || {};
|
||||
this.contractsManager = options.contractsManager;
|
||||
this.rpcHost = options.blockchainConfig.rpcHost;
|
||||
this.rpcPort = options.blockchainConfig.rpcPort;
|
||||
this.rpcHost = options.blockchainConfig && options.blockchainConfig.rpcHost;
|
||||
this.rpcPort = options.blockchainConfig && options.blockchainConfig.rpcPort;
|
||||
this.plugins = options.plugins || new Plugins({});
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ Compiler.prototype.compile_solidity = function(contractFiles) {
|
|||
for (var i = 0; i < contractFiles.length; i++){
|
||||
// TODO: this depends on the config
|
||||
var filename = contractFiles[i].filename.replace('app/contracts/','');
|
||||
console.log("normal compile " + filename);
|
||||
input[filename] = contractFiles[i].content.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,14 @@ var Config = function(options) {
|
|||
};
|
||||
|
||||
Config.prototype.loadConfigFiles = function(options) {
|
||||
var interceptLogs = options.interceptLogs;
|
||||
if (options.interceptLogs === undefined) {
|
||||
interceptLogs = true;
|
||||
}
|
||||
this.embarkConfig = JSON.parse(fs.readFileSync(options.embarkConfig));
|
||||
this.embarkConfig.plugins = this.embarkConfig.plugins || {};
|
||||
|
||||
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger});
|
||||
this.plugins = new Plugins({plugins: this.embarkConfig.plugins, logger: this.logger, interceptLogs: interceptLogs});
|
||||
this.plugins.loadPlugins();
|
||||
|
||||
this.loadPipelineConfigFile();
|
||||
|
@ -66,7 +70,6 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
var envContractsConfig = configObject[this.env];
|
||||
|
||||
var mergedConfig = merge.recursive(defaultContractsConfig, envContractsConfig);
|
||||
console.log(JSON.stringify(mergedConfig));
|
||||
this.contractsConfig = mergedConfig;
|
||||
};
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ ContractsManager.prototype.build = function(done) {
|
|||
contract.functionHashes = compiledContract.functionHashes;
|
||||
contract.abiDefinition = compiledContract.abiDefinition;
|
||||
|
||||
contract.gas = (contractConfig && contractConfig.gas) || self.contractsConfig.gas;
|
||||
contract.gas = (contractConfig && contractConfig.gas) || self.contractsConfig.gas || 'auto';
|
||||
adjustGas(contract);
|
||||
|
||||
contract.gasPrice = contract.gasPrice || self.contractsConfig.gasPrice;
|
||||
|
|
|
@ -33,7 +33,6 @@ Pipeline.prototype.build = function(abi) {
|
|||
pipelinePlugins.forEach(function(plugin) {
|
||||
try {
|
||||
if (file.options && file.options.skipPipeline) {
|
||||
console.log("skipping");
|
||||
return;
|
||||
}
|
||||
file.content = plugin.runPipeline({targetFile: file.filename, source: file.content});
|
||||
|
|
|
@ -9,6 +9,7 @@ var Plugin = function(options) {
|
|||
this.pluginModule = options.pluginModule;
|
||||
this.pluginPath = options.pluginPath;
|
||||
this.pluginConfig = options.pluginConfig;
|
||||
this.shouldInterceptLogs = options.interceptLogs;
|
||||
this.clientWeb3Providers = [];
|
||||
this.contractsGenerators = [];
|
||||
this.pipeline = [];
|
||||
|
@ -22,7 +23,9 @@ var Plugin = function(options) {
|
|||
};
|
||||
|
||||
Plugin.prototype.loadPlugin = function() {
|
||||
if (this.shouldInterceptLogs) {
|
||||
this.interceptLogs(this.pluginModule);
|
||||
}
|
||||
(this.pluginModule.call(this, this));
|
||||
};
|
||||
|
||||
|
@ -36,7 +39,8 @@ Plugin.prototype.pathToFile = function(filename) {
|
|||
|
||||
Plugin.prototype.interceptLogs = function(context) {
|
||||
var self = this;
|
||||
context.console = console;
|
||||
// TODO: this is a bit nasty, figure out a better way
|
||||
context.console = context.console || console;
|
||||
context.console.error = function(txt) {
|
||||
// TODO: logger should support an array instead of a single argument
|
||||
//self.logger.error.apply(self.logger, arguments);
|
||||
|
|
|
@ -3,6 +3,7 @@ var path = require('path');
|
|||
|
||||
var Plugins = function(options) {
|
||||
this.pluginList = options.plugins || [];
|
||||
this.interceptLogs = options.interceptLogs;
|
||||
this.plugins = [];
|
||||
// TODO: need backup 'NullLogger'
|
||||
this.logger = options.logger;
|
||||
|
@ -28,7 +29,7 @@ Plugins.prototype.loadPlugin = function(pluginName, pluginConfig) {
|
|||
var pluginPath = path.join(process.env.PWD, 'node_modules', pluginName);
|
||||
var plugin = require(pluginPath);
|
||||
|
||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath});
|
||||
var pluginWrapper = new Plugin({name: pluginName, pluginModule: plugin, pluginConfig: pluginConfig, logger: this.logger, pluginPath: pluginPath, interceptLogs: this.interceptLogs});
|
||||
pluginWrapper.loadPlugin();
|
||||
this.plugins.push(pluginWrapper);
|
||||
};
|
||||
|
|
46
lib/test.js
46
lib/test.js
|
@ -7,23 +7,27 @@ var TestLogger = require('./test_logger.js');
|
|||
var Config = require('./config.js');
|
||||
var ABIGenerator = require('./abi.js');
|
||||
|
||||
// TODO: load config file
|
||||
// TODO: include plugins
|
||||
var Test = function(options) {
|
||||
//try {
|
||||
this.sim = require('ethereumjs-testrpc');
|
||||
//} catch(e) {
|
||||
// this.sim = false;
|
||||
//}
|
||||
|
||||
//if (this.sim === false) {
|
||||
// console.log('Simulator not found; Please install it with "npm install -g ethereumjs-testrpc');
|
||||
// console.log('For more information see https://github.com/ethereumjs/testrpc');
|
||||
// exit();
|
||||
//}
|
||||
try {
|
||||
this.sim = require('ethereumjs-testrpc');
|
||||
} catch (e) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') {
|
||||
console.log('Simulator not found; Please install it with "npm install ethereumjs-testrpc --save"');
|
||||
console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save"');
|
||||
console.log('For more information see https://github.com/ethereumjs/testrpc');
|
||||
exit();
|
||||
} else {
|
||||
console.log("==============");
|
||||
console.log("Tried to load testrpc but an error occurred. This is a problem with testrpc");
|
||||
console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save". Alternatively install node 6.9.1 and the testrpc 3.0');
|
||||
console.log("==============");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
this.web3 = new Web3();
|
||||
this.web3.setProvider(this.sim.provider(options));
|
||||
this.web3.setProvider(this.sim.provider());
|
||||
};
|
||||
|
||||
Test.prototype.deployAll = function(contractsConfig, cb) {
|
||||
|
@ -33,21 +37,20 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
async.waterfall([
|
||||
function getConfig(callback) {
|
||||
var config = new Config({env: 'test', logger: logger});
|
||||
config.loadConfigFiles({embarkConfig: 'embark.json'});
|
||||
config.loadConfigFiles({embarkConfig: 'embark.json', interceptLogs: false});
|
||||
config.contractsConfig = {contracts: contractsConfig};
|
||||
callback(null, config);
|
||||
},
|
||||
function buildContracts(callback) {
|
||||
//var config = new Config({env: 'test'});
|
||||
//config.contractsFiles = config.loadFiles(["app/contracts/**"]);
|
||||
config.contractsConfig = {contracts: contractsConfig} ;
|
||||
|
||||
function buildContracts(config, callback) {
|
||||
var contractsManager = new ContractsManager({
|
||||
contractFiles: config.contractsFiles,
|
||||
contractsConfig: config.contractsConfig,
|
||||
logger: logger,
|
||||
plugins: config.plugins
|
||||
});
|
||||
contractsManager.build(callback);
|
||||
contractsManager.build(function() {
|
||||
callback(null, contractsManager);
|
||||
});
|
||||
},
|
||||
function deployContracts(contractsManager, callback) {
|
||||
var deploy = new Deploy({
|
||||
|
@ -76,10 +79,9 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
}
|
||||
var web3 = self.web3;
|
||||
web3.eth.defaultAccount = accounts[0];
|
||||
console.log("hello!");
|
||||
// TODO: replace evals with separate process so it's isolated and with
|
||||
// a callback
|
||||
//eval(result); // jshint ignore:line
|
||||
eval(result); // jshint ignore:line
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue