From 70868de81b6a0ed48294fb098e8547ec6c581e46 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 19:29:19 +0900 Subject: [PATCH 01/16] changes undefined process.exit(code) to process.exit(9) --- lib/cmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cmd.js b/lib/cmd.js index a3440b974..d28a1b9d3 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -33,10 +33,11 @@ Cmd.prototype.newApp = function() { .description('new application') .action(function(name, options) { if (name === undefined) { + console.log("please specify your app Name".red); console.log("e.g embark new MyApp".green); console.log("e.g embark new --help for more information".green); - process.exit(code); + process.exit(9); } self.Embark.generateTemplate('boilerplate', './', name); }); From 5525e1e9d46fd0bca42733e857d81cd625c4274e Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 22:49:42 +0900 Subject: [PATCH 02/16] add this.timeout(15000) to tests to allow the solc enough space to work --- test/compiler.js | 2 ++ test/contracts.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/compiler.js b/test/compiler.js index c44d3ed9b..806da7aec 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -12,6 +12,8 @@ describe('embark.Compiler', function() { var compiler = new Compiler({logger: new TestLogger({})}); describe('#compile_solidity', function() { + this.timeout(15000); + var expectedObject = {}; expectedObject["SimpleStorage"] = {"code":"606060405234610000576040516020806100f083398101604052515b60008190555b505b60bf806100316000396000f300606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","realRuntimeBytecode": "606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820","runtimeBytecode":"606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","swarmHash": "a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe70390350007722","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"}]}; diff --git a/test/contracts.js b/test/contracts.js index 873383a19..58a7b053c 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -9,6 +9,8 @@ var readFile = function(file) { }; describe('embark.Contratcs', function() { + this.timeout(15000); + describe('simple', function() { var contractsManager = new ContractsManager({ contractFiles: [ From 895b2477cdd022c307ccda024eae5d52b701e093 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 22:52:06 +0900 Subject: [PATCH 03/16] added unit test for Embark.Cmd --- test/cmd.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/cmd.js diff --git a/test/cmd.js b/test/cmd.js new file mode 100644 index 000000000..5afe1e45f --- /dev/null +++ b/test/cmd.js @@ -0,0 +1,30 @@ +var Embark = require('../lib/index'); +var Cmd = require('../lib/cmd'); + +describe('embark.Cmd', function () { + var cmd = new Cmd(Embark); + + describe('#new', function () { + it('it should not create an app without a name', function (done) { + cmd.newApp(undefined, function (output) { + let lines = output.split('\n'); + assert.equal(lines[0], 'please specify your app Name'); + assert.equal(lines[1], 'e.g embark new MyApp'); + assert.equal(lines[2], 'e.g embark new --help for more information'); + }); + done(); + }); + + it('it should create an app with a name', function (done) { + let appname = 'deleteapp'; + cmd.newApp(appname, function (output) { + let lines = output.split('\n'); + assert.equal(lines[0], 'Initializing Embark Template....'); + assert.equal(lines[1], 'Installing packages.. this can take a few seconds'); + assert.equal(lines[2], 'Init complete'); + assert.equal(lines[3], 'App ready at ./' + appname); + }); + done(); + }); + }); +}); \ No newline at end of file From 6f5abfe07c92398df0eaba618a7da919ff66d7b5 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 22:56:27 +0900 Subject: [PATCH 04/16] swap let -> var --- test/cmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cmd.js b/test/cmd.js index 5afe1e45f..8b64a97dd 100644 --- a/test/cmd.js +++ b/test/cmd.js @@ -7,7 +7,7 @@ describe('embark.Cmd', function () { describe('#new', function () { it('it should not create an app without a name', function (done) { cmd.newApp(undefined, function (output) { - let lines = output.split('\n'); + var lines = output.split('\n'); assert.equal(lines[0], 'please specify your app Name'); assert.equal(lines[1], 'e.g embark new MyApp'); assert.equal(lines[2], 'e.g embark new --help for more information'); @@ -16,9 +16,9 @@ describe('embark.Cmd', function () { }); it('it should create an app with a name', function (done) { - let appname = 'deleteapp'; + var appname = 'deleteapp'; cmd.newApp(appname, function (output) { - let lines = output.split('\n'); + var lines = output.split('\n'); assert.equal(lines[0], 'Initializing Embark Template....'); assert.equal(lines[1], 'Installing packages.. this can take a few seconds'); assert.equal(lines[2], 'Init complete'); From 2a8fa33b840d09f947bb46db5917754c61e5588c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Tenorio-Forn=C3=A9s?= Date: Wed, 8 Mar 2017 15:18:57 +0100 Subject: [PATCH 05/16] fix typo in index.js Remove an unexpected + sign preceding a simple instruction. --- demo/app/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/app/js/index.js b/demo/app/js/index.js index cd5863c79..8b3f1bb35 100644 --- a/demo/app/js/index.js +++ b/demo/app/js/index.js @@ -93,7 +93,7 @@ $(document).ready(function() { if (err) { $("#communication .error").show(); $("#communication-controls").hide(); -+ $("#status-communication").addClass('status-offline'); + $("#status-communication").addClass('status-offline'); } else { EmbarkJS.Messages.setProvider('whisper'); $("#status-communication").addClass('status-online'); From 486fbec108388989b975ab6c6a6abbd1e231b5d1 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:20:23 +0900 Subject: [PATCH 06/16] read version in from package.json instead of strings --- lib/core/engine.js | 3 ++- lib/dashboard/monitor.js | 3 ++- lib/index.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index 872d8fc7a..df17ce908 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -9,12 +9,13 @@ var ServicesMonitor = require('./services.js'); var Pipeline = require('../pipeline/pipeline.js'); var Server = require('../pipeline/server.js'); var Watch = require('../pipeline/watch.js'); +var version = require('../../package.json')['version']; var Engine = function(options) { this.env = options.env; this.embarkConfig = options.embarkConfig; this.interceptLogs = options.interceptLogs; - this.version = "2.4.0"; + this.version = version; }; Engine.prototype.init = function(_options) { diff --git a/lib/dashboard/monitor.js b/lib/dashboard/monitor.js index 5468128ba..bbce536db 100644 --- a/lib/dashboard/monitor.js +++ b/lib/dashboard/monitor.js @@ -2,9 +2,10 @@ var blessed = require("blessed"); var CommandHistory = require('./command_history.js'); +var version = require('../../package.json')['version']; function Dashboard(options) { - var title = (options && options.title) || "Embark 2.4.0"; + var title = (options && options.title) || "Embark " + version; this.env = options.env; this.console = options.console; this.history = new CommandHistory(); diff --git a/lib/index.js b/lib/index.js index 97877acb5..a6662f48f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,10 +22,11 @@ var IPFS = require('./upload/ipfs.js'); var Swarm = require('./upload/swarm.js'); var Cmd = require('./cmd.js'); +var version = require('../package.json')['version']; var Embark = { - version: '2.4.0', + version: version, process: function(args) { var cmd = new Cmd(Embark); From 7a930d95a8e0f555fa9aff8fdaea790632b17e78 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:28:10 +0900 Subject: [PATCH 07/16] switch config to grunt vs declaring in test --- Gruntfile.coffee | 2 ++ test/compiler.js | 1 - test/contracts.js | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 24f23def8..b3eb1166a 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -21,6 +21,8 @@ module.exports = (grunt) -> mochaTest: test: src: ['test/**/*.js'] + options: + timeout: 0 jshint: all: ['bin/embark', 'lib/**/*.js', 'js/mine.js', 'js/embark.js'] diff --git a/test/compiler.js b/test/compiler.js index 806da7aec..19c05843c 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -12,7 +12,6 @@ describe('embark.Compiler', function() { var compiler = new Compiler({logger: new TestLogger({})}); describe('#compile_solidity', function() { - this.timeout(15000); var expectedObject = {}; diff --git a/test/contracts.js b/test/contracts.js index 58a7b053c..57b65bcf3 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -9,7 +9,6 @@ var readFile = function(file) { }; describe('embark.Contratcs', function() { - this.timeout(15000); describe('simple', function() { var contractsManager = new ContractsManager({ From ac2a75791c6fcd2b166edabd01d26b7f380c4e81 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:38:08 +0900 Subject: [PATCH 08/16] grunt-config-mocha does not accept 0 as an option for timeout, so we set the value in the test itself --- test/compiler.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/compiler.js b/test/compiler.js index 19c05843c..9cbd1126a 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -12,6 +12,7 @@ describe('embark.Compiler', function() { var compiler = new Compiler({logger: new TestLogger({})}); describe('#compile_solidity', function() { + this.timeout(0); var expectedObject = {}; From 026909aa912bf9d99d0cdc37784df669c7de6402 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:41:16 +0900 Subject: [PATCH 09/16] fix other timeout issues in tests outside of core framework code --- boilerplate/test/contract_spec.js | 1 + demo/test/simple_storage_spec.js | 1 + lib/cmd.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/boilerplate/test/contract_spec.js b/boilerplate/test/contract_spec.js index ec1b87383..e732155dc 100644 --- a/boilerplate/test/contract_spec.js +++ b/boilerplate/test/contract_spec.js @@ -5,6 +5,7 @@ var web3 = EmbarkSpec.web3; //describe("SimpleStorage", function() { // before(function(done) { +// this.timeout(0); // var contractsConfig = { // "SimpleStorage": { // args: [100, '0x123'] diff --git a/demo/test/simple_storage_spec.js b/demo/test/simple_storage_spec.js index 83ad1610f..b2d3cb178 100644 --- a/demo/test/simple_storage_spec.js +++ b/demo/test/simple_storage_spec.js @@ -5,6 +5,7 @@ var web3 = EmbarkSpec.web3; describe("SimpleStorage", function() { before(function(done) { + this.timeout(0); var contractsConfig = { "SimpleStorage": { args: [100] diff --git a/lib/cmd.js b/lib/cmd.js index a3440b974..91d966e4b 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -120,7 +120,7 @@ Cmd.prototype.test = function() { .command('test') .description('run tests') .action(function() { - shelljs.exec('mocha test/ --no-timeouts'); + shelljs.exec('mocha test'); }); }; From 82042c01c6f5d322438244409cd6c6297ab0ab73 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Wed, 8 Mar 2017 09:46:15 -0500 Subject: [PATCH 10/16] Fixed issue with logic to detect if IPFS node is online. If the IPFS node is not running and there's another service in the computer running on port 5001 it could cause an exception. --- lib/core/services.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/core/services.js b/lib/core/services.js index a04f672eb..ad2f8c078 100644 --- a/lib/core/services.js +++ b/lib/core/services.js @@ -70,18 +70,23 @@ ServicesMonitor.prototype.check = function() { body += d; }); res.on('end', function() { - var parsed = JSON.parse(body); - if(parsed.Version){ - result.push(("IPFS " + parsed.Version).green); + try{ + var parsed = JSON.parse(body); + if(parsed.Version){ + result.push(("IPFS " + parsed.Version).green); + } + else{ + result.push("IPFS".green); + } } - else{ - result.push("IPFS".green); + catch (e){ + result.push("IPFS".red); } callback(null, result); }); res.on('error', function(err) { self.logger.trace("Check IPFS version error: " + err); - result.push("IPFS".green); + result.push("IPFS".red); callback(null, result); }); }); @@ -93,8 +98,8 @@ ServicesMonitor.prototype.check = function() { }); }, function checkDevServer(result, callback) { - var host = self.serverHost || self.config.webServerConfig.host; - var port = self.serverPort || self.config.webServerConfig.port; + var host = self.config.webServerConfig.host || self.serverHost; + var port = self.config.webServerConfig.port || self.serverPort; self.logger.trace('checkDevServer'); var devServer = 'Webserver (http://' + host + ':' + port + ')'; devServer = (self.runWebserver) ? devServer.green : devServer.red; From b003a30b3b4a6434a53adccef7a37f34ecde5160 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:49:43 +0900 Subject: [PATCH 11/16] add version from package.json in test for contracts --- test/console.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/console.js b/test/console.js index a1d987e12..42ca6f540 100644 --- a/test/console.js +++ b/test/console.js @@ -2,10 +2,11 @@ var Console = require('../lib/dashboard/console.js'); var Plugins = require('../lib/core/plugins.js'); var assert = require('assert'); +var version = require('../package.json')['version']; describe('embark.Console', function() { var plugins = new Plugins({plugins: {}}); - var console = new Console({plugins: plugins, version: '2.3.1'}); + var console = new Console({plugins: plugins, version: version}); describe('#executeCmd', function() { @@ -14,7 +15,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.3.1'); + assert.equal(lines[0], 'Welcome to Embark ' + version); assert.equal(lines[2], 'possible commands are:'); done(); }); From f5aafa424220a2d95bfc947e752aa562d121a52b Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Wed, 8 Mar 2017 09:51:58 -0500 Subject: [PATCH 12/16] Setting host and port parameters back according to develop branch --- lib/core/services.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/services.js b/lib/core/services.js index ad2f8c078..90fb5e0b8 100644 --- a/lib/core/services.js +++ b/lib/core/services.js @@ -98,8 +98,8 @@ ServicesMonitor.prototype.check = function() { }); }, function checkDevServer(result, callback) { - var host = self.config.webServerConfig.host || self.serverHost; - var port = self.config.webServerConfig.port || self.serverPort; + var host = self.serverHost || self.config.webServerConfig.host; + var port = self.serverPort || self.config.webServerConfig.port; self.logger.trace('checkDevServer'); var devServer = 'Webserver (http://' + host + ':' + port + ')'; devServer = (self.runWebserver) ? devServer.green : devServer.red; From 83f3e1c5eef8dd5e17d9cbcd1089a8b322a0d44a Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:52:17 +0900 Subject: [PATCH 13/16] dot notation preferred --- lib/core/engine.js | 2 +- lib/dashboard/monitor.js | 2 +- lib/index.js | 2 +- test/console.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index df17ce908..ad248a7c6 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -9,7 +9,7 @@ var ServicesMonitor = require('./services.js'); var Pipeline = require('../pipeline/pipeline.js'); var Server = require('../pipeline/server.js'); var Watch = require('../pipeline/watch.js'); -var version = require('../../package.json')['version']; +var version = require('../../package.json').version; var Engine = function(options) { this.env = options.env; diff --git a/lib/dashboard/monitor.js b/lib/dashboard/monitor.js index bbce536db..210fa7cec 100644 --- a/lib/dashboard/monitor.js +++ b/lib/dashboard/monitor.js @@ -2,7 +2,7 @@ var blessed = require("blessed"); var CommandHistory = require('./command_history.js'); -var version = require('../../package.json')['version']; +var version = require('../../package.json').version; function Dashboard(options) { var title = (options && options.title) || "Embark " + version; diff --git a/lib/index.js b/lib/index.js index a6662f48f..6b358d23b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,7 +22,7 @@ var IPFS = require('./upload/ipfs.js'); var Swarm = require('./upload/swarm.js'); var Cmd = require('./cmd.js'); -var version = require('../package.json')['version']; +var version = require('../package.json').version; var Embark = { diff --git a/test/console.js b/test/console.js index 42ca6f540..a0f9d6e29 100644 --- a/test/console.js +++ b/test/console.js @@ -2,7 +2,7 @@ var Console = require('../lib/dashboard/console.js'); var Plugins = require('../lib/core/plugins.js'); var assert = require('assert'); -var version = require('../package.json')['version']; +var version = require('../package.json').version; describe('embark.Console', function() { var plugins = new Plugins({plugins: {}}); From f4ef1af4a1843f180963081cd5085efbaa5e2657 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 23:56:00 +0900 Subject: [PATCH 14/16] fixed failing timeouts in abi tests --- Gruntfile.coffee | 3 +-- test/abi.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index b3eb1166a..f645af422 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -21,8 +21,7 @@ module.exports = (grunt) -> mochaTest: test: src: ['test/**/*.js'] - options: - timeout: 0 + jshint: all: ['bin/embark', 'lib/**/*.js', 'js/mine.js', 'js/embark.js'] diff --git a/test/abi.js b/test/abi.js index 4d2533ba3..e54798b2f 100644 --- a/test/abi.js +++ b/test/abi.js @@ -5,7 +5,7 @@ var assert = require('assert'); // TODO: instead 'eval' the code with a fake web3 object // and check the generate code interacts as expected describe('embark.ABIGenerator', function() { - + this.timeout(0); describe('#generateProvider', function() { var generator = new ABIGenerator({blockchainConfig: {rpcHost: 'somehost', rpcPort: '1234'}, contractsManager: {}}); From 90ddfb8c840b8783a88753293a0389e2fba8a2fd Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Thu, 9 Mar 2017 00:00:43 +0900 Subject: [PATCH 15/16] ignore jetbrains folders --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 75be4c5f7..162b9c4d7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ test_app/.embark/development/ test_app/config/production/password test_app/node_modules/ test_app/chains.json +.idea \ No newline at end of file From 511c92bd9cfbbc88d2d835281bfef87e67c5112f Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Wed, 8 Mar 2017 22:37:04 -0500 Subject: [PATCH 16/16] Updated the link on boilerplate app (generated by embark new) to point to the latest documentation instead of old wiki --- boilerplate/app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplate/app/index.html b/boilerplate/app/index.html index 3585f0803..8068e7c7b 100644 --- a/boilerplate/app/index.html +++ b/boilerplate/app/index.html @@ -6,6 +6,6 @@

Welcome to Embark!

-

See the Wiki to see what you can do with Embark!

+

See the Embark's documentation to see what you can do with Embark!