From 51e39c5b74eeda7798cb8632f35a61416dd9afea Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 8 Nov 2018 17:11:45 -0500 Subject: [PATCH] fix(simulator): change port depending of the type in config --- cmd/cmd_controller.js | 1 + lib/modules/blockchain_process/simulator.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 4d1bb209d..d7e49227a 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -40,6 +40,7 @@ class EmbarkController { let Simulator = require('../lib/modules/blockchain_process/simulator.js'); let simulator = new Simulator({ blockchainConfig: this.config.blockchainConfig, + contractsConfig: this.config.contractsConfig, logger: this.logger }); simulator.run(options); diff --git a/lib/modules/blockchain_process/simulator.js b/lib/modules/blockchain_process/simulator.js index e9a3d711e..6ea68ff47 100644 --- a/lib/modules/blockchain_process/simulator.js +++ b/lib/modules/blockchain_process/simulator.js @@ -10,6 +10,7 @@ const fs = require('../../core/fs.js'); class Simulator { constructor(options) { this.blockchainConfig = options.blockchainConfig; + this.contractsConfig = options.contractsConfig; this.logger = options.logger; } @@ -30,7 +31,8 @@ class Simulator { let useProxy = this.blockchainConfig.proxy || false; let host = (dockerHostSwap(options.host || this.blockchainConfig.rpcHost) || defaultHost); - let port = (options.port || this.blockchainConfig.rpcPort || 8545); + const configPort = this.contractsConfig.deployment.type === 'rpc' ? this.blockchainConfig.rpcPort : this.blockchainConfig.wsPort; + let port = (options.port || configPort || 8545); port = parseInt(port, 10) + (useProxy ? constants.blockchain.servicePortOnProxy : 0); cmds.push("-p " + port);