From 097088821b41c89ba8a5fb1b6771706e98b33017 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 19:27:23 -0500 Subject: [PATCH 01/10] support generating abi file only --- lib/config.js | 5 ++++- lib/pipeline.js | 2 ++ test_app/embark.json | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/config.js b/lib/config.js index b89672532..b017291db 100644 --- a/lib/config.js +++ b/lib/config.js @@ -198,8 +198,11 @@ Config.prototype.loadFiles = function(files) { }).filter(function(file) { if (file === 'embark.js') { return; + } else if (file === 'abi.js') { + readFiles.push({filename: file, content: "", path: file}); + } else { + readFiles.push({filename: file, content: fs.readFileSync(file).toString(), path: file}); } - readFiles.push({filename: file, content: fs.readFileSync(file).toString(), path: file}); }); return readFiles; diff --git a/lib/pipeline.js b/lib/pipeline.js index 517208ae4..13e5ddb4b 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -21,6 +21,8 @@ Pipeline.prototype.build = function(abi) { if (file.filename === 'embark.js') { return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true}; + } else if (file.filename === 'abi.js') { + return {content: abi, filename: file.filename, path: file.path, modified: true}; } else if (['web3.js', 'ipfs.js', 'ipfs-api.js', 'orbit.js'].indexOf(file.filename) >= 0) { file.modified = true; return file; diff --git a/test_app/embark.json b/test_app/embark.json index 731b6063f..3f5136de0 100644 --- a/test_app/embark.json +++ b/test_app/embark.json @@ -4,6 +4,7 @@ "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/**"], + "js/abi.js": "abi.js", "index.html": "app/index.html", "test.html": "app/test.html" }, From 63da0773ae10d19b27ddc6687dd57314e08ef5a6 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 19:32:29 -0500 Subject: [PATCH 02/10] log creating directory as a trace log level --- lib/pipeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pipeline.js b/lib/pipeline.js index 13e5ddb4b..5301f7135 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -48,7 +48,7 @@ Pipeline.prototype.build = function(abi) { }); var dir = targetFile.split('/').slice(0, -1).join('/'); - self.logger.info("creating dir " + this.buildDir + dir); + self.logger.trace("creating dir " + this.buildDir + dir); mkdirp.sync(this.buildDir + dir); // if it's a directory From a511979cd190fcd75bf0dc8a72260c2bda356aa8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 20:08:47 -0500 Subject: [PATCH 03/10] make console output clearer --- lib/deploy.js | 8 ++++---- lib/monitor.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/deploy.js b/lib/deploy.js index 43be72819..d2c50692e 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -61,7 +61,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args); if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") { - self.logger.info(contract.className + " already deployed " + trackedContract.address); + self.logger.info(contract.className.cyan + " already deployed at ".green + trackedContract.address.cyan); contract.deployedAddress = trackedContract.address; self.logger.contractsState(self.contractsManager.contractsState()); return callback(); @@ -118,12 +118,12 @@ Deploy.prototype.deployContract = function(contract, params, callback) { gasPrice: contract.gasPrice }); - self.logger.info("deploying " + contract.className + " with " + contract.gas + " gas"); + self.logger.info("deploying " + contract.className.cyan + " with ".green + contract.gas + " gas".green); contractParams.push(function(err, transaction) { self.logger.contractsState(self.contractsManager.contractsState()); if (err) { - self.logger.error("error deploying contract: " + contract.className); + self.logger.error("error deploying contract: " + contract.className.cyan); var errMsg = err.toString(); if (errMsg === 'Error: The contract code couldn\'t be stored, please check your gas amount.') { errMsg = 'The contract code couldn\'t be stored, out of gas or constructor error'; @@ -132,7 +132,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) { contract.error = errMsg; return callback(new Error(err)); } else if (transaction.address !== undefined) { - self.logger.info(contract.className + " deployed at " + transaction.address); + self.logger.info(contract.className.cyan + " deployed at ".green + transaction.address.cyan); contract.deployedAddress = transaction.address; contract.transactionHash = transaction.transactionHash; return callback(null, transaction.address); diff --git a/lib/monitor.js b/lib/monitor.js index 2ef7c5693..c89a44b8b 100644 --- a/lib/monitor.js +++ b/lib/monitor.js @@ -358,7 +358,7 @@ Dashboard.prototype.layoutCmd = function() { this.input.on('submit', function(data) { if (data !== '') { self.history.addCommand(data); - self.logText.log('console> ' + data); + self.logText.log('console> '.bold.green + data); self.console.executeCmd(data, function(result) { self.logText.log(result); }); From bd99a75048418ab074916b38f7bd1a919c8fa455 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 20:24:42 -0500 Subject: [PATCH 04/10] advice user when an unknown command is typed in the console --- lib/console.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/console.js b/lib/console.js index 6e57e0ff3..8df883aca 100644 --- a/lib/console.js +++ b/lib/console.js @@ -36,7 +36,11 @@ Console.prototype.executeCmd = function(cmd, callback) { return callback(result); } catch(e) { - return callback(e.message.red); + if (e.message.indexOf('not defined') > 0) { + return callback(("error: " + e.message).red + ("\nType " + "help".bold + " to see the list of available commands").cyan); + } else { + return callback(e.message); + } } }; From 617d40086cf54806889b2ac2cf7ca4658629c4c4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 20:35:42 -0500 Subject: [PATCH 05/10] add web3 to console help --- lib/console.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/console.js b/lib/console.js index 8df883aca..cee3ae1f5 100644 --- a/lib/console.js +++ b/lib/console.js @@ -22,6 +22,9 @@ Console.prototype.executeCmd = function(cmd, callback) { 'Welcome to Embark 2', '', 'possible commands are:', + // TODO: only if the blockchain is actually active! + // will need to pass te current embark state here + 'web3 - instantiated web3.js object configured to the current environment', 'quit - to immediatly exit', '', 'The web3 object and the interfaces for the deployed contrats and their methods are also available' From fcd88b9e4a7f50ea8de3640558722f21f3551323 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 20:56:18 -0500 Subject: [PATCH 06/10] reorder component initialization make log clearer; improve log messages to make them clearer --- lib/console.js | 3 ++- lib/deploy.js | 8 ++++---- lib/index.js | 39 ++++++++++++++++++++------------------- lib/pipeline.js | 4 ++-- lib/server.js | 2 +- lib/watch.js | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/console.js b/lib/console.js index cee3ae1f5..c9cd02bd6 100644 --- a/lib/console.js +++ b/lib/console.js @@ -2,6 +2,7 @@ var Web3 = require('web3'); var Console = function(options) { this.plugins = options.plugins; + this.version = options.version; }; Console.prototype.runCode = function(code) { @@ -19,7 +20,7 @@ Console.prototype.executeCmd = function(cmd, callback) { if (cmd === 'help') { var helpText = [ - 'Welcome to Embark 2', + 'Welcome to Embark ' + this.version, '', 'possible commands are:', // TODO: only if the blockchain is actually active! diff --git a/lib/deploy.js b/lib/deploy.js index d2c50692e..a8b86b61e 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -61,7 +61,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args); if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") { - self.logger.info(contract.className.cyan + " already deployed at ".green + trackedContract.address.cyan); + self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan); contract.deployedAddress = trackedContract.address; self.logger.contractsState(self.contractsManager.contractsState()); return callback(); @@ -118,7 +118,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) { gasPrice: contract.gasPrice }); - self.logger.info("deploying " + contract.className.cyan + " with ".green + contract.gas + " gas".green); + self.logger.info("deploying " + contract.className.bold.cyan + " with ".green + contract.gas + " gas".green); contractParams.push(function(err, transaction) { self.logger.contractsState(self.contractsManager.contractsState()); @@ -132,7 +132,7 @@ Deploy.prototype.deployContract = function(contract, params, callback) { contract.error = errMsg; return callback(new Error(err)); } else if (transaction.address !== undefined) { - self.logger.info(contract.className.cyan + " deployed at ".green + transaction.address.cyan); + self.logger.info(contract.className.bold.cyan + " deployed at ".green + transaction.address.bold.cyan); contract.deployedAddress = transaction.address; contract.transactionHash = transaction.transactionHash; return callback(null, transaction.address); @@ -158,7 +158,7 @@ Deploy.prototype.deployAll = function(done) { self.logger.error(err.message); self.logger.debug(err.stack); } - self.logger.info("finished"); + self.logger.info("finished deploying contracts"); self.logger.trace(arguments); done(); } diff --git a/lib/index.js b/lib/index.js index ffc5af6af..8cc7063b2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -79,7 +79,7 @@ var Embark = { callback(); }, function startConsole(callback) { - Embark.console = new Console({plugins: self.plugins}); + Embark.console = new Console({plugins: self.plugins, version: self.version}); callback(); }, function startMonitor(callback) { @@ -101,6 +101,13 @@ var Embark = { // TODO: do this after monitor is rendered callback(); }, + function displayLoadedPlugins(callback) { + var pluginList = self.plugins.listPlugins(); + if (pluginList.length > 0) { + self.logger.info("loaded plugins: " + pluginList.join(", ")); + } + callback(); + }, function monitorServices(callback) { if (!options.useDashboard) { return callback(); @@ -117,18 +124,6 @@ var Embark = { callback(); }, self.buildDeployGenerate.bind(self), - function startAssetServer(callback) { - if (!options.runWebserver) { - return callback(); - } - self.logger.setStatus("Starting Server"); - var server = new Server({ - logger: self.logger, - host: options.serverHost, - port: options.serverPort - }); - server.start(callback); - }, function watchFilesForChanges(callback) { self.logger.setStatus("Watching for changes"); var watch = new Watch({logger: self.logger}); @@ -144,19 +139,25 @@ var Embark = { }); callback(); }, - function displayLoadedPlugins(callback) { - var pluginList = self.plugins.listPlugins(); - if (pluginList.length > 0) { - self.logger.info("loaded plugins: " + pluginList.join(", ")); + function startAssetServer(callback) { + if (!options.runWebserver) { + return callback(); } - callback(); + self.logger.setStatus("Starting Server"); + var server = new Server({ + logger: self.logger, + host: options.serverHost, + port: options.serverPort + }); + server.start(callback); } ], function(err, result) { if (err) { self.logger.error(err.message); } else { self.logger.setStatus("Ready".green); - self.logger.trace("finished".underline); + self.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline); + self.logger.info("Ready".underline); } }); }, diff --git a/lib/pipeline.js b/lib/pipeline.js index 5301f7135..042ada1a4 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -62,7 +62,7 @@ Pipeline.prototype.build = function(abi) { contentFiles.map(function(file) { var filename = file.filename.replace('app/', ''); filename = filename.replace(targetDir, ''); - self.logger.info("writing file " + self.buildDir + targetDir + filename); + self.logger.info("writing file " + (self.buildDir + targetDir + filename).bold.dim); fs.writeFileSync(self.buildDir + targetDir + filename, fs.readFileSync(file.path)); }); @@ -71,7 +71,7 @@ Pipeline.prototype.build = function(abi) { return file.content; }).join("\n"); - self.logger.info("writing file " + this.buildDir + targetFile); + self.logger.info("writing file " + (this.buildDir + targetFile).bold.dim); fs.writeFileSync(this.buildDir + targetFile, content); } } diff --git a/lib/server.js b/lib/server.js index fd32c4c5e..afbdad2a8 100644 --- a/lib/server.js +++ b/lib/server.js @@ -16,7 +16,7 @@ Server.prototype.start = function(callback) { serve(req, res, finalhandler(req, res)); }); - this.logger.info(("webserver available at http://" + this.hostname + ":" + this.port).underline.green); + this.logger.info("webserver available at " + ("http://" + this.hostname + ":" + this.port).bold.underline.green); server.listen(this.port, this.hostname) ; callback(); }; diff --git a/lib/watch.js b/lib/watch.js index 42092c8eb..9c94e1d84 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -25,7 +25,7 @@ Watch.prototype.start = function() { self.logger.trace('ready to watch config changes'); }); - this.logger.info("ready to watch changes"); + this.logger.info("ready to watch file changes"); }; Watch.prototype.watchAssets = function(embarkConfig, callback) { From b8bd7a44a0fefe5c65ef50f66c48856f78760edb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 21:10:54 -0500 Subject: [PATCH 07/10] add readme to testapp --- test_app/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test_app/README.md diff --git a/test_app/README.md b/test_app/README.md new file mode 100644 index 000000000..47ad5712f --- /dev/null +++ b/test_app/README.md @@ -0,0 +1,8 @@ +Test App for integration testing purposes. + +```../bin/embark run``` to check if everything is behaving as expected + +```../bin/embark test``` to see tests are working as expected + +```dist/index.html``` and ```dist/test.html``` to check different functionality + From d14943e95da7394636880c81ed362b25f8ab88ea Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Feb 2017 21:13:45 -0500 Subject: [PATCH 08/10] update test --- test/console.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/console.js b/test/console.js index c523b2711..96eaa4a48 100644 --- a/test/console.js +++ b/test/console.js @@ -5,7 +5,7 @@ var assert = require('assert'); describe('embark.Console', function() { var plugins = new Plugins({plugins: {}}); - var console = new Console({plugins: plugins}); + var console = new Console({plugins: plugins, version: '2.3.1'}); describe('#executeCmd', function() { @@ -14,7 +14,7 @@ describe('embark.Console', function() { it('it should provide a help text', function(done) { console.executeCmd('help', function(output) { var lines = output.split('\n'); - assert.equal(lines[0], 'Welcome to Embark 2'); + assert.equal(lines[0], 'Welcome to Embark 2.3.1'); assert.equal(lines[2], 'possible commands are:'); done(); }); From 27a3a9c3f24d6d7e14f893a6bb1fcee3708e23e4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 17 Feb 2017 06:16:56 -0500 Subject: [PATCH 09/10] clean up compiler file; remove unused code --- lib/compiler.js | 74 ------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index c89fbbe50..eeca92b98 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,9 +1,5 @@ /*jshint esversion: 6, loopfunc: true */ -var shelljs = require('shelljs'); -var shelljs_global = require('shelljs/global'); -var fs = require('fs'); var solc = require('solc'); -var merge = require('merge'); var Compiler = function(options) { this.plugins = options.plugins; @@ -75,74 +71,4 @@ Compiler.prototype.compile_solidity = function(contractFiles) { return compiled_object; }; -Compiler.prototype.compile_serpent = function(contractFiles) { - var cmd, result, output, json, compiled_object; - - //TODO: figure out how to compile multiple files and get the correct json - var contractFile = contractFiles[0]; - - cmd = "serpent compile " + contractFile; - - result = exec(cmd, {silent: true}); - code = result.output; - - if (result.code === 1) { - throw new Error(result.output); - } - - cmd = "serpent mk_full_signature " + contractFile; - result = exec(cmd, {silent: true}); - - if (result.code === 1) { - throw new Error(result.output); - } - - json = JSON.parse(result.output.trim()); - className = contractFile.split('.')[0].split("/").pop(); - - for (var i=0; i < json.length; i++) { - var elem = json[i]; - - if (elem.outputs.length > 0) { - elem.constant = true; - } - } - - compiled_object = {}; - compiled_object[className] = {}; - compiled_object[className].code = code.trim(); - compiled_object[className].info = {}; - compiled_object[className].abiDefinition = json; - - return compiled_object; -}; - -Compiler.prototype.compile = function(contractFiles) { - var solidity = [], serpent = []; - - for (var i = 0; i < contractFiles.length; i++) { - var contractParts = contractFiles[i].split('.'), - extension = contractParts[contractParts.length-1]; - - if (extension === 'sol') { - solidity.push(contractFiles[i]); - } - else if (extension === 'se') { - serpent.push(contractFiles[i]); - } - else { - throw new Error("extension not known, got " + extension); - } - } - - var contracts = []; - if (solidity.length > 0) { - contracts.concat(this.compile_solidity(solidity)); - } - if (serpent.length > 0) { - contracts.concat(this.compile_serpent(serpent)); - } - return contracts; -}; - module.exports = Compiler; From c339732cd66f422f22b2012b1d4df07199f19add Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 17 Feb 2017 07:14:44 -0500 Subject: [PATCH 10/10] make compiler module async --- lib/compiler.js | 43 ++++++++++++++++++++++++++++++------------- lib/contracts.js | 7 +++++-- test/compiler.js | 15 ++++++++------- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index eeca92b98..80cc86121 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,11 +1,23 @@ /*jshint esversion: 6, loopfunc: true */ var solc = require('solc'); +var async = require('async'); + +function asyncEachObject(object, iterator, callback) { + async.each( + Object.keys(object || {}), + function(key, next){ + iterator(key, object[key], next); + }, + callback + ); +} +async.eachObject = asyncEachObject; var Compiler = function(options) { this.plugins = options.plugins; }; -Compiler.prototype.compile_contracts = function(contractFiles) { +Compiler.prototype.compile_contracts = function(contractFiles, cb) { var available_compilers = { //".se": this.compile_serpent @@ -25,20 +37,25 @@ Compiler.prototype.compile_contracts = function(contractFiles) { var compiledObject = {}; - // TODO: warn about files it doesn't know how to compile - for (var extension in available_compilers) { - var compiler = available_compilers[extension]; - var matchingFiles = contractFiles.filter(function(file) { - return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension); - }); + async.eachObject(available_compilers, + function(extension, compiler, callback) { + // TODO: warn about files it doesn't know how to compile + var matchingFiles = contractFiles.filter(function(file) { + return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension); + }); - Object.assign(compiledObject, compiler.call(compiler, matchingFiles || [])); - } - - return compiledObject; + compiler.call(compiler, matchingFiles || [], function(compileResult) { + Object.assign(compiledObject, compileResult); + callback(); + }); + }, + function (err) { + cb(compiledObject); + } + ); }; -Compiler.prototype.compile_solidity = function(contractFiles) { +Compiler.prototype.compile_solidity = function(contractFiles, cb) { var input = {}; for (var i = 0; i < contractFiles.length; i++){ @@ -68,7 +85,7 @@ Compiler.prototype.compile_solidity = function(contractFiles) { compiled_object[className].abiDefinition = JSON.parse(contract.interface); } - return compiled_object; + cb(compiled_object); }; module.exports = Compiler; diff --git a/lib/contracts.js b/lib/contracts.js index 369fdb45e..d8bfd51e7 100644 --- a/lib/contracts.js +++ b/lib/contracts.js @@ -39,12 +39,15 @@ ContractsManager.prototype.build = function(done) { async.waterfall([ function compileContracts(callback) { var compiler = new Compiler({plugins: self.plugins}); + // TODO: check if try is still needed try { - self.compiledContracts = compiler.compile_contracts(self.contractFiles); + compiler.compile_contracts(self.contractFiles, function(compiledObject) { + self.compiledContracts = compiledObject; + callback(); + }); } catch(err) { return callback(new Error(err.message)); } - return callback(); }, function prepareContractsFromConfig(callback) { var className, contract; diff --git a/test/compiler.js b/test/compiler.js index d39b99934..e5e6724cb 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -11,19 +11,20 @@ describe('embark.Compiler', function() { var compiler = new Compiler({}); describe('#compile_solidity', function() { - var compiledContracts = compiler.compile_solidity([ - readFile('test/contracts/simple_storage.sol'), - readFile('test/contracts/token.sol') - ]); - var expectedObject = {}; expectedObject["SimpleStorage"] = {"code":"606060405234610000576040516020806100f083398101604052515b60008190555b505b60bf806100316000396000f300606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","runtimeBytecode":"606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","gasEstimates":{"creation":[20131,38200],"external":{"get()":269,"set(uint256)":20163,"storedData()":224},"internal":{}},"functionHashes":{"get()":"6d4ce63c","set(uint256)":"60fe47b1","storedData()":"2a1afcd9"},"abiDefinition":[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"type":"constructor"}]}; expectedObject["Token"] = {"code":"6060604052346100005760405160208061048e83398101604052515b600160a060020a033316600090815260208190526040902081905560028190555b505b6104418061004d6000396000f3006060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461006157806318160ddd1461009157806323b872dd146100b057806370a08231146100e6578063a9059cbb14610111578063dd62ed3e14610141575b610000565b346100005761007d600160a060020a0360043516602435610172565b604080519115158252519081900360200190f35b346100005761009e6101dd565b60408051918252519081900360200190f35b346100005761007d600160a060020a03600435811690602435166044356101e4565b604080519115158252519081900360200190f35b346100005761009e600160a060020a03600435166102f8565b60408051918252519081900360200190f35b346100005761007d600160a060020a0360043516602435610317565b604080519115158252519081900360200190f35b346100005761009e600160a060020a03600435811690602435166103da565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b6002545b90565b600160a060020a0383166000908152602081905260408120548290101561020a57610000565b600160a060020a03808516600090815260016020908152604080832033909416835292905220548290101561023e57610000565b600160a060020a0383166000908152602081905260409020546102619083610407565b151561026c57610000565b600160a060020a038085166000818152600160209081526040808320338616845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060015b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290101561033d57610000565b600160a060020a0383166000908152602081905260409020546103609083610407565b151561036b57610000565b600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060015b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b808201829010155b929150505600a165627a7a7230582017291fa7c1b9234972e866bb8b730096a40f8610da4684f7977498fc0ee8f75b0029","runtimeBytecode":"6060604052361561005c5763ffffffff60e060020a600035041663095ea7b3811461006157806318160ddd1461009157806323b872dd146100b057806370a08231146100e6578063a9059cbb14610111578063dd62ed3e14610141575b610000565b346100005761007d600160a060020a0360043516602435610172565b604080519115158252519081900360200190f35b346100005761009e6101dd565b60408051918252519081900360200190f35b346100005761007d600160a060020a03600435811690602435166044356101e4565b604080519115158252519081900360200190f35b346100005761009e600160a060020a03600435166102f8565b60408051918252519081900360200190f35b346100005761007d600160a060020a0360043516602435610317565b604080519115158252519081900360200190f35b346100005761009e600160a060020a03600435811690602435166103da565b60408051918252519081900360200190f35b600160a060020a03338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b6002545b90565b600160a060020a0383166000908152602081905260408120548290101561020a57610000565b600160a060020a03808516600090815260016020908152604080832033909416835292905220548290101561023e57610000565b600160a060020a0383166000908152602081905260409020546102619083610407565b151561026c57610000565b600160a060020a038085166000818152600160209081526040808320338616845282528083208054889003905583835282825280832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060015b9392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600160a060020a0333166000908152602081905260408120548290101561033d57610000565b600160a060020a0383166000908152602081905260409020546103609083610407565b151561036b57610000565b600160a060020a0333811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060015b92915050565b600160a060020a038083166000908152600160209081526040808320938516835292905220545b92915050565b808201829010155b929150505600a165627a7a7230582017291fa7c1b9234972e866bb8b730096a40f8610da4684f7977498fc0ee8f75b0029","gasEstimates":{"creation":[40422,217800],"external":{"allowance(address,address)":598,"approve(address,uint256)":22273,"balanceOf(address)":462,"totalSupply()":265,"transfer(address,uint256)":42894,"transferFrom(address,address,uint256)":63334},"internal":{"safeToAdd(uint256,uint256)":41}},"functionHashes":{"allowance(address,address)":"dd62ed3e","approve(address,uint256)":"095ea7b3","balanceOf(address)":"70a08231","totalSupply()":"18160ddd","transfer(address,uint256)":"a9059cbb","transferFrom(address,address,uint256)":"23b872dd"},"abiDefinition":[{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"value","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"_allowance","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initial_balance","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]} - it('should generate compiled code and abi', function() { - assert.deepEqual(compiledContracts, expectedObject); + it('should generate compiled code and abi', function(done) { + compiler.compile_solidity([ + readFile('test/contracts/simple_storage.sol'), + readFile('test/contracts/token.sol') + ], function(compiledContracts) { + assert.deepEqual(compiledContracts, expectedObject); + done(); + }); }); });