mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-27 04:40:43 +00:00
speed up testing
This commit is contained in:
parent
32953f7204
commit
124177c8fc
@ -1,6 +1,3 @@
|
|||||||
var async = require('async');
|
|
||||||
var Web3 = require('web3');
|
|
||||||
|
|
||||||
var getSimulator = function() {
|
var getSimulator = function() {
|
||||||
try {
|
try {
|
||||||
return require('ethereumjs-testrpc');
|
return require('ethereumjs-testrpc');
|
||||||
@ -20,29 +17,21 @@ var getSimulator = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var Test;
|
||||||
var Test = function(options) {
|
Test = (function (options) {
|
||||||
|
var async = require('async');
|
||||||
var opts = options === undefined ? {} : options;
|
var opts = options === undefined ? {} : options;
|
||||||
opts.logLevel = opts.hasOwnProperty('logLevel') ? opts.logLevel : 'debug';
|
opts.logLevel = opts.hasOwnProperty('logLevel') ? opts.logLevel : 'debug';
|
||||||
opts.simulatorOptions = opts.hasOwnProperty('simulatorOptions') ? opts.simulatorOptions : {};
|
opts.simulatorOptions = opts.hasOwnProperty('simulatorOptions') ? opts.simulatorOptions : {};
|
||||||
|
var sim = getSimulator();
|
||||||
|
|
||||||
function newWebThree() {
|
function newWebThree() {
|
||||||
try {
|
try {
|
||||||
var Web3 = require('web3');
|
var Web3 = require('web3');
|
||||||
var web3 = new Web3();
|
var web3 = new Web3();
|
||||||
web3.setProvider(getSimulator());
|
web3.setProvider(sim.provider(opts.simulatorOptions));
|
||||||
|
return web3;
|
||||||
} catch (e) {
|
} 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');
|
|
||||||
// TODO: should throw exception instead
|
|
||||||
return process.exit();
|
|
||||||
}
|
|
||||||
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 new Error(e);
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,20 +47,16 @@ var Test = function(options) {
|
|||||||
// TODO: confi will need to detect if this is a obj
|
// TODO: confi will need to detect if this is a obj
|
||||||
embarkConfig: opts.embarkConfig || 'embark.json',
|
embarkConfig: opts.embarkConfig || 'embark.json',
|
||||||
interceptLogs: false
|
interceptLogs: false
|
||||||
}).init();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function newLogger() {
|
self.web3 = newWebThree();
|
||||||
var TestLogger = require('./test_logger.js');
|
self.engine = newEngine();
|
||||||
new TestLogger({logLevel: opts.logLevel})
|
self.engine.init();
|
||||||
}
|
|
||||||
|
|
||||||
this.engine = newEngine();
|
|
||||||
this.web3 = newWebThree();
|
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function getConfig(callback) {
|
function getConfig(callback) {
|
||||||
contractsConfig = { contracts: contractsConfig };
|
self.engine.config.contractsConfig = {contracts: contractsConfig};
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
function startServices(callback) {
|
function startServices(callback) {
|
||||||
@ -114,8 +99,9 @@ var Test = function(options) {
|
|||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
deployAll: deployAll
|
deployAll: deployAll,
|
||||||
}
|
sim: sim
|
||||||
}();
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
module.exports = Test;
|
module.exports = Test;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
//require("./core/debug_util.js")(__filename, async);
|
// require("./utils/debug_util.js")(__filename, async);
|
||||||
|
|
||||||
var colors = require('colors');
|
var colors = require('colors');
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"embark": "../",
|
"embark": "file:../",
|
||||||
"mocha": "^2.2.5"
|
"mocha": "^2.2.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var Embark = require('embark');
|
var EmbarkSpec = require('embark/lib/core/test.js');
|
||||||
//TODO: this path is temporary to handle the scope of Embark within an app
|
|
||||||
var EmbarkSpec = require('../node_modules/embark/lib/core/test.js');
|
|
||||||
var web3 = EmbarkSpec.web3;
|
|
||||||
|
|
||||||
describe("AnotherStorage", function() {
|
describe("AnotherStorage", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var Embark = require('embark');
|
var EmbarkSpec = require('embark/lib/core/test.js');
|
||||||
var EmbarkSpec = require('../node_modules/embark/lib/core/test.js');
|
|
||||||
var web3 = EmbarkSpec.web3;
|
|
||||||
|
|
||||||
describe("SimpleStorage", function() {
|
describe("SimpleStorage", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var Embark = require('embark');
|
var EmbarkSpec = require('embark/lib/core/test.js');
|
||||||
var EmbarkSpec = require('../node_modules/embark/lib/core/test.js');
|
|
||||||
var Embark = require('embark');
|
|
||||||
var EmbarkSpec = Embark.initTests();
|
|
||||||
var web3 = EmbarkSpec.web3;
|
|
||||||
|
|
||||||
describe("Token", function() {
|
describe("Token", function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user