From 7599f43a3b697fd9a37d0fc590e7869e6a041691 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Thu, 30 Mar 2017 20:48:22 +0900 Subject: [PATCH] fixed problem with double this.client in blockchain.js --- lib/cmds/blockchain/blockchain.js | 26 +++++++-------- test/blockchain.js | 54 +++++++++++++++---------------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 78a06449d..1162fd80a 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -18,7 +18,7 @@ class Blockchain { constructor(options) { this.blockchainConfig = options.blockchainConfig; this.env = options.env || 'development'; - this.client = BlockchainClient(this.blockchainConfig, 'geth', this.env); + this.client = options.client; this.config = { geth_bin: this.blockchainConfig.geth_bin || 'geth', @@ -47,18 +47,18 @@ class Blockchain { return shelljs.exec(cmd); } -run () { - var self = this; - console.log("===============================================================================".magenta); - console.log("===============================================================================".magenta); - console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta); - console.log("===============================================================================".magenta); - console.log("===============================================================================".magenta); - let address = this.initChainAndGetAddress(); - this.client.mainCommand(address, function(cmd) { - shelljs.exec(cmd, {async : true}); - }); -} + run () { + var self = this; + console.log("===============================================================================".magenta); + console.log("===============================================================================".magenta); + console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta); + console.log("===============================================================================".magenta); + console.log("===============================================================================".magenta); + let address = this.initChainAndGetAddress(); + this.client.mainCommand(address, function(cmd) { + shelljs.exec(cmd, {async : true}); + }); + } initChainAndGetAddress() { let address = null, result; diff --git a/test/blockchain.js b/test/blockchain.js index befdd3100..25e7b9c6b 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -1,47 +1,45 @@ /*globals describe, it*/ const Blockchain = require('../lib/cmds/blockchain/blockchain'); -// let BlockchainClient = require('../lib/cmds/blockchain/blockchain_client'); + const assert = require('assert'); -describe('embark.Blockchain', function() { +describe('embark.Blockchain', function () { //let Client = function() {}; //Client.prototype.name = "ClientName"; - describe('#initializer', function() { + describe('#initializer', function () { //let client = new Client(); - describe('with empty config', function() { - it('should have a default config', function() { + describe('with empty config', function () { + it('should have a default config', function () { let config = { - blockchainConfig: { - networkType: 'custom', - genesisBlock: false, - geth_bin: 'geth', - datadir: false, - mineWhenNeeded: false, - rpcHost: 'localhost', - rpcPort: 8545, - rpcApi: ['eth', 'web3', 'net'], - rpcCorsDomain: false, - networkId: 12301, - port: 30303, - nodiscover: false, - maxpeers: 25, - mine: false, - vmdebug: false, - whisper: true, - account: {}, - bootnodes: "", - } - } + networkType: 'custom', + genesisBlock: false, + geth_bin: 'geth', + datadir: false, + mineWhenNeeded: false, + rpcHost: 'localhost', + rpcPort: 8545, + rpcApi: ['eth', 'web3', 'net'], + rpcCorsDomain: false, + networkId: 12301, + port: 30303, + nodiscover: false, + maxpeers: 25, + mine: false, + vmdebug: false, + whisper: true, + account: {}, + bootnodes: "" + }; let blockchain = new Blockchain(config, 'geth'); assert.deepEqual(blockchain.config, config); }); }); - describe('with config', function() { - it('should take config params', function() { + describe('with config', function () { + it('should take config params', function () { let config = { networkType: 'livenet', genesisBlock: 'foo/bar/genesis.json',