diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 7a51704f..9ecd918e 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -556,7 +556,11 @@ class EmbarkController { engine.startService("processManager"); engine.startService("libraryManager"); engine.startService("web3", {wait: true}); - engine.startService("deployment"); + engine.startService("deployment", { + trackContracts: false, + compileOnceOnly: true, + disableOptimizations: options.coverage + }); engine.startService("codeGenerator"); engine.startService("codeRunner"); engine.startService("codeCoverage"); diff --git a/lib/core/config.js b/lib/core/config.js index c6e547f1..e531e106 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -197,16 +197,16 @@ Config.prototype.loadBlockchainConfigFile = function() { this.blockchainConfig.default = true; } - if (this.blockchainConfig.targetGasLimit && this.blockchainConfig.targetGasLimit.match(unitRegex)) { + if (this.blockchainConfig.targetGasLimit && this.blockchainConfig.targetGasLimit.toString().match(unitRegex)) { this.blockchainConfig.targetGasLimit = utils.getWeiBalanceFromString(this.blockchainConfig.targetGasLimit, web3); } - if (this.blockchainConfig.gasPrice && this.blockchainConfig.gasPrice.match(unitRegex)) { + if (this.blockchainConfig.gasPrice && this.blockchainConfig.gasPrice.toString().match(unitRegex)) { this.blockchainConfig.gasPrice = utils.getWeiBalanceFromString(this.blockchainConfig.gasPrice, web3); } - if (this.blockchainConfig.account && this.blockchainConfig.account.balance && this.blockchainConfig.account.balance.match(unitRegex)) { - this.blockchainConfig.account.balance = utils.getWeiBalanceFromString(this.blockchainConfig.account.balance, web3); + if (this.blockchainConfig.account && this.blockchainConfig.account.balance && this.blockchainConfig.account.balance.toString().match(unitRegex)) { + this.blockchainConfig.account.balance = utils.getWeiBalanceFromString(this.blockchainConfig.account.balance, web3); } if ( diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index 3ac1d315..79552d6c 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -377,12 +377,12 @@ class ENS { function getResolverAddress(next) { self.ensContract.methods.resolver(hashedName).call((err, resolverAddress) => { if (err) { - next(err); - } else if(resolverAddress === '0x0000000000000000000000000000000000000000') { - next('Name not yet registered'); - } else { - next(null, resolverAddress); + return next(err); } + if(resolverAddress === '0x0000000000000000000000000000000000000000') { + return next('Name not yet registered'); + } + next(null, resolverAddress); }); }, function createResolverContract(resolverAddress, next) { @@ -395,7 +395,13 @@ class ENS { function resolveName(resolverContract, next) { resolverContract.methods.addr(hashedName).call(next); } - ], cb); + ], (err, result) => { + if (err) { + self.logger.error(__('Failed to resolve the ENS name: %s', name)); + return cb(err); + } + cb(null, result); + }); } } diff --git a/lib/modules/specialconfigs/index.js b/lib/modules/specialconfigs/index.js index a181f70a..d4eb465d 100644 --- a/lib/modules/specialconfigs/index.js +++ b/lib/modules/specialconfigs/index.js @@ -92,6 +92,9 @@ class SpecialConfigs { const self = this; const logFunction = silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger); async.each(onDeployCode, (cmd, eachCb) => { + if (!cmd) { + return eachCb(); + } logFunction("==== executing: " + cmd); self.events.request('runcode:eval', cmd, (err) => { if (err && err.message.indexOf("invalid opcode") >= 0) { @@ -123,7 +126,13 @@ class SpecialConfigs { self.replaceWithAddresses(cmd, next); }, self.replaceWithENSAddress.bind(self) - ], nextMapCb); + ], (err, code) => { + if (err) { + self.logger.error(err.message || err); + return nextMapCb(); // Don't return error as we just skip the failing command + } + nextMapCb(null, code); + }); }, (err, onDeployCode) => { if (err) { return cb(new Error("error running onDeploy for " + contract.className.cyan)); diff --git a/lib/modules/tests/index.js b/lib/modules/tests/index.js index 8e811be6..9f7025f4 100644 --- a/lib/modules/tests/index.js +++ b/lib/modules/tests/index.js @@ -126,7 +126,7 @@ class TestRunner { async.waterfall([ function setupGlobalNamespace(next) { const test = new Test({loglevel: options.loglevel, node: options.node, events: self.events, logger: self.logger, - config: self.embark.config, ipc: self.ipc}); + config: self.embark.config, ipc: self.ipc, coverage: options.coverage}); global.embark = test; global.assert = assert; global.config = test.config.bind(test); @@ -203,7 +203,7 @@ class TestRunner { console.info('Running solc tests'); let solcTest = new SolcTest({loglevel: options.loglevel, node: options.node, events: this.events, logger: this.logger, - config: this.embark.config, ipc: this.ipc}); + config: this.embark.config, ipc: this.ipc, coverage: options.coverage}); global.embark = solcTest; async.waterfall([ function initEngine(next) { diff --git a/test_apps/test_app/test/token_spec.js b/test_apps/test_app/test/token_spec.js index adfdce6f..85fd4e6b 100644 --- a/test_apps/test_app/test/token_spec.js +++ b/test_apps/test_app/test/token_spec.js @@ -82,7 +82,7 @@ describe("Token", function () { assert.strictEqual(result, MyToken.options.address); }); - it("should not deploy if deployIf returns false", async function() { + it("should not deploy if deployIf returns false", function() { assert.ok(!SomeContract.options.address); }); });