From 8471d8fa0f06d703c168a39dec8fcdc52e406656 Mon Sep 17 00:00:00 2001 From: hodlbank Date: Mon, 15 Jan 2018 21:55:28 +0000 Subject: [PATCH] Fixing issue #324: add options to configure simulator's mnemonic and block time. --- boilerplate/config/blockchain.json | 4 +++- demo/config/blockchain.json | 4 +++- lib/cmds/simulator.js | 13 ++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/boilerplate/config/blockchain.json b/boilerplate/config/blockchain.json index 961c8be6..c09eb765 100644 --- a/boilerplate/config/blockchain.json +++ b/boilerplate/config/blockchain.json @@ -16,7 +16,9 @@ "wsOrigins": "http://localhost:8000", "wsRPC": true, "wsHost": "localhost", - "wsPort": 8546 + "wsPort": 8546, + "simulatorMnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", + "simulatorBlocktime": 0 }, "testnet": { "enabled": true, diff --git a/demo/config/blockchain.json b/demo/config/blockchain.json index 215b68c4..ee452ee8 100644 --- a/demo/config/blockchain.json +++ b/demo/config/blockchain.json @@ -16,7 +16,9 @@ "wsOrigins": "http://localhost:8000", "wsRPC": true, "wsHost": "localhost", - "wsPort": 8546 + "wsPort": 8546, + "simulatorMnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", + "simulatorBlocktime": 0 }, "testnet": { "enabled": true, diff --git a/lib/cmds/simulator.js b/lib/cmds/simulator.js index af4dc316..71cc1fbd 100644 --- a/lib/cmds/simulator.js +++ b/lib/cmds/simulator.js @@ -14,9 +14,20 @@ class Simulator { cmds.push("-e " + (options.defaultBalance || 100)); cmds.push("-l " + (options.gasLimit || 8000000)); + // adding mnemonic only if it is defined in the blockchainConfig or options + let simulatorMnemonic = this.blockchainConfig.simulatorMnemonic || options.simulatorMnemonic; + if (simulatorMnemonic) { + cmds.push("--mnemonic \"" + (simulatorMnemonic) +"\""); + } + + // adding blocktime only if it is defined in the blockchainConfig or options + let simulatorBlocktime = this.blockchainConfig.simulatorBlocktime || options.simulatorBlocktime; + if (simulatorBlocktime) { + cmds.push("-b \"" + (simulatorBlocktime) +"\""); + } + shelljs.exec('testrpc ' + cmds.join(' '), {async : true}); } } module.exports = Simulator; -