Commit e14d029c authored by Iuri Matias's avatar Iuri Matias

refactor deployer into a waterfall

parent 30d67d66
......@@ -26,7 +26,7 @@ var runTest = function(filename, web3) {
},
function runTests(contracts, next) {
let test = contracts.MyTest;
TestRunner.runTest("SimpleStorage", test, accounts, next);
TestRunner.runTest("SimpleStorage", test, next);
}
], function() {
});
......
......@@ -5,6 +5,8 @@ var async = require('async');
function deployAll(compileResult, web3, accounts, callback) {
let compiledObject = {}, contracts = {};
async.waterfall([
function getContractData(next) {
for (let contractFile in compileResult) {
for (let contractName in compileResult[contractFile]) {
let contract = compileResult[contractFile][contractName];
......@@ -23,8 +25,10 @@ function deployAll(compileResult, web3, accounts, callback) {
compiledObject[className].className = className;
}
}
async.eachOfLimit(compiledObject, 1, function(contract, contractName, next) {
next();
},
function deployContracts(next) {
async.eachOfLimit(compiledObject, 1, function(contract, contractName, nextEach) {
let contractObject = new web3.eth.Contract(contract.abi);
let contractCode = "0x" + contract.code;
......@@ -57,11 +61,14 @@ function deployAll(compileResult, web3, accounts, callback) {
contracts[contractName] = contractObject;
next();
nextEach();
});
}, function() {
callback(null, contracts);
next(null, contracts);
});
}
], callback);
}
module.exports = {
......
......@@ -2,7 +2,7 @@ var async = require('async');
var changeCase = require('change-case');
require('colors');
function runTest(testName, testObject, accounts, callback) {
function runTest(testName, testObject, callback) {
let runList = [];
let specialFunctions = ['beforeAll'];
let availableFunctions = testObject._jsonInterface.filter((x) => x.type === 'function').map((x) => x.name);
......
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