Commit d7669a2b authored by Iuri Matias's avatar Iuri Matias

refactor waterfall and cleanup, pass file to compile module

parent 477c38bf
var async = require('async'); var async = require('async');
let remixLib = require('remix-lib');
let Compiler = require('./src/compiler.js'); let Compiler = require('./src/compiler.js');
let Deployer = require('./src/deployer.js'); let Deployer = require('./src/deployer.js');
...@@ -10,17 +9,12 @@ var runTest = function(contractName, contractObj, cb) { ...@@ -10,17 +9,12 @@ var runTest = function(contractName, contractObj, cb) {
} }
var runTestFile = function(filename, web3) { var runTestFile = function(filename, web3) {
let result, accounts, contracts;
async.waterfall([ async.waterfall([
function compile(next) { function compile(next) {
Compiler.compileAll(function(err, compilationResult) { Compiler.compileFile(filename, next);
result = compilationResult;
next();
});
}, },
function deployAllContracts(next) { function deployAllContracts(compilationResult, next) {
Deployer.deployAll(result, web3, next); Deployer.deployAll(compilationResult, web3, next);
}, },
function runTests(contracts, next) { function runTests(contracts, next) {
runTest("SimpleStorage", contracts.MyTest, next); runTest("SimpleStorage", contracts.MyTest, next);
...@@ -29,7 +23,7 @@ var runTestFile = function(filename, web3) { ...@@ -29,7 +23,7 @@ var runTestFile = function(filename, web3) {
}); });
} }
module.exports = { module.exports = {
runTestFile: runTestFile runTestFile: runTestFile,
runTest: runTest
}; };
...@@ -6,13 +6,13 @@ let compilerInput = remixLib.helpers.compiler; ...@@ -6,13 +6,13 @@ let compilerInput = remixLib.helpers.compiler;
let RemixCompiler = require('remix-solidity').Compiler; let RemixCompiler = require('remix-solidity').Compiler;
// TODO: replace this with remix's own compiler code // TODO: replace this with remix's own compiler code
function compileAll(cb) { function compileFile(filename, cb) {
console.log("compile all"); console.log("compile all");
let compiler; let compiler;
const sources = { const sources = {
"simple_storage.sol": {content: fs.readFileSync("examples/simple_storage.sol").toString()},
"tests.sol": {content: fs.readFileSync("sol/tests.sol").toString()}, "tests.sol": {content: fs.readFileSync("sol/tests.sol").toString()},
"simple_storage.sol": {content: fs.readFileSync("examples/simple_storage.sol").toString()},
"simple_storage_test.sol": {content: fs.readFileSync("examples/simple_storage_test.sol").toString()} "simple_storage_test.sol": {content: fs.readFileSync("examples/simple_storage_test.sol").toString()}
}; };
...@@ -39,6 +39,6 @@ function compileAll(cb) { ...@@ -39,6 +39,6 @@ function compileAll(cb) {
} }
module.exports = { module.exports = {
compileAll: compileAll compileFile: compileFile
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment