/*globals describe, it*/
const Blockchain = require('../lib/cmds/blockchain/blockchain');
const constants = require('../lib/constants.json');

const assert = require('assert');

describe('embark.Blockchain', function () {
  //let Client = function() {};
  //Client.prototype.name = "ClientName";

  describe('#initializer', function () {
    //let client = new Client();

    describe('with empty config', function () {
      it('should have a default config', function (done) {
        let config = {
          networkType: 'custom',
          genesisBlock: false,
          geth_bin: 'geth',
          datadir: false,
          mineWhenNeeded: false,
          rpcHost: 'localhost',
          rpcPort: 8545,
          rpcApi: ['eth', 'web3', 'net', 'debug'],
          rpcCorsDomain: false,
          networkId: 12301,
          port: 30303,
          nodiscover: false,
          maxpeers: 25,
          mine: false,
          vmdebug: false,
          whisper: true,
          account: {},
          bootnodes: "",
          wsApi: ["eth", "web3", "net", "shh", "debug"],
          wsHost: "localhost",
          wsOrigins: false,
          wsPort: 8546,
          wsRPC: true,
          targetGasLimit: false,
          syncMode: undefined,
          syncmode: undefined,
          verbosity: undefined,
          proxy: true
        };
        let blockchain = new Blockchain(config, 'geth');

        if(config.proxy){
          config.wsPort += constants.blockchain.servicePortOnProxy;
          config.rpcPort += constants.blockchain.servicePortOnProxy;
        }
        assert.deepEqual(blockchain.config, config);
        done();
      });
    });

    describe('with config', function () {
      it('should take config params', function (done) {
        let config = {
          networkType: 'livenet',
          genesisBlock: 'foo/bar/genesis.json',
          geth_bin: 'geth',
          datadir: '/foo/datadir/',
          mineWhenNeeded: true,
          rpcHost: 'someserver',
          rpcPort: 12345,
          rpcApi: ['eth', 'web3', 'net', 'debug'],
          rpcCorsDomain: true,
          networkId: 1,
          port: 123456,
          nodiscover: true,
          maxpeers: 25,
          mine: true,
          vmdebug: false,
          whisper: false,
          account: {},
          bootnodes: "",
          wsApi: ["eth", "web3", "net", "shh", "debug"],
          wsHost: "localhost",
          wsOrigins: false,
          wsPort: 8546,
          wsRPC: true,
          targetGasLimit: false,
          syncMode: undefined,
          syncmode: undefined,
          verbosity: undefined,
          proxy: true
        };
        let blockchain = new Blockchain(config, 'geth');

        if(config.proxy){
          config.wsPort += constants.blockchain.servicePortOnProxy;
          config.rpcPort += constants.blockchain.servicePortOnProxy;
        }

        assert.deepEqual(blockchain.config, config);
        done();
      });
    });

  });
});

@@ -134,16 +134,68 @@
 .json');
+%0Aconst %7BdefaultHost%7D = require('../lib/utils/host');
 %0A%0Aconst 
@@ -721,19 +721,19 @@
 st: 
-'localh
+defaultH
 ost
-'
 ,%0A  
@@ -1135,35 +1135,35 @@
     wsHost: 
-%22localh
+defaultH
 ost
-%22
 ,%0A          
@@ -2028,20 +2028,19 @@
 st: 
-'someserver'
+defaultHost
 ,%0A  
@@ -2446,19 +2446,19 @@
 st: 
-%22localh
+defaultH
 ost
-%22
 ,%0A  
@@ -2493,34 +2493,35 @@
         wsPort: 
-85
+123
 46,%0A          ws

revise blockchain test re: docker awareness