From 7b991bb58aafa360d10002896bd33a1d69cc6204 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 7 Nov 2019 13:02:16 -0600 Subject: [PATCH] refactor(@embark/plugins/geth): don't run empty commands The `WhisperGethClient` returns empty strings for its "new account" and "list accounts" commands; if a command is an empty string then `Blockchain` should not execute it. --- packages/plugins/geth/src/blockchain.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/plugins/geth/src/blockchain.js b/packages/plugins/geth/src/blockchain.js index 80ffc84a5..c2939c570 100644 --- a/packages/plugins/geth/src/blockchain.js +++ b/packages/plugins/geth/src/blockchain.js @@ -313,7 +313,9 @@ Blockchain.prototype.initDevChain = function(callback) { // Create other accounts async.waterfall([ function listAccounts(next) { - self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => { + const listAccountsCommand = self.client.listAccountsCommand(); + if (!listAccountsCommand) return next(null, 0); + self.runCommand(listAccountsCommand, {}, (err, stdout, _stderr) => { if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) { console.log(__("no accounts found").green); return next(); @@ -330,6 +332,8 @@ Blockchain.prototype.initDevChain = function(callback) { }); }, function newAccounts(accountsToCreate, next) { + const newAccountCommand = self.client.newAccountCommand(); + if (!newAccountCommand) return next(); var accountNumber = 0; async.whilst( function() { @@ -337,7 +341,7 @@ Blockchain.prototype.initDevChain = function(callback) { }, function(callback) { accountNumber++; - self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => { + self.runCommand(newAccountCommand, {}, (err, stdout, _stderr) => { if (err) { return callback(err, accountNumber); }