fixed problem with double this.client in blockchain.js
This commit is contained in:
parent
fbe3f302b2
commit
7599f43a3b
|
@ -18,7 +18,7 @@ class Blockchain {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.blockchainConfig = options.blockchainConfig;
|
this.blockchainConfig = options.blockchainConfig;
|
||||||
this.env = options.env || 'development';
|
this.env = options.env || 'development';
|
||||||
this.client = BlockchainClient(this.blockchainConfig, 'geth', this.env);
|
this.client = options.client;
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
geth_bin: this.blockchainConfig.geth_bin || 'geth',
|
geth_bin: this.blockchainConfig.geth_bin || 'geth',
|
||||||
|
@ -47,18 +47,18 @@ class Blockchain {
|
||||||
return shelljs.exec(cmd);
|
return shelljs.exec(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
run () {
|
run () {
|
||||||
var self = this;
|
var self = this;
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
let address = this.initChainAndGetAddress();
|
let address = this.initChainAndGetAddress();
|
||||||
this.client.mainCommand(address, function(cmd) {
|
this.client.mainCommand(address, function(cmd) {
|
||||||
shelljs.exec(cmd, {async : true});
|
shelljs.exec(cmd, {async : true});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initChainAndGetAddress() {
|
initChainAndGetAddress() {
|
||||||
let address = null, result;
|
let address = null, result;
|
||||||
|
|
|
@ -1,47 +1,45 @@
|
||||||
/*globals describe, it*/
|
/*globals describe, it*/
|
||||||
const Blockchain = require('../lib/cmds/blockchain/blockchain');
|
const Blockchain = require('../lib/cmds/blockchain/blockchain');
|
||||||
// let BlockchainClient = require('../lib/cmds/blockchain/blockchain_client');
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
describe('embark.Blockchain', function() {
|
describe('embark.Blockchain', function () {
|
||||||
//let Client = function() {};
|
//let Client = function() {};
|
||||||
//Client.prototype.name = "ClientName";
|
//Client.prototype.name = "ClientName";
|
||||||
|
|
||||||
describe('#initializer', function() {
|
describe('#initializer', function () {
|
||||||
//let client = new Client();
|
//let client = new Client();
|
||||||
|
|
||||||
describe('with empty config', function() {
|
describe('with empty config', function () {
|
||||||
it('should have a default config', function() {
|
it('should have a default config', function () {
|
||||||
let config = {
|
let config = {
|
||||||
blockchainConfig: {
|
networkType: 'custom',
|
||||||
networkType: 'custom',
|
genesisBlock: false,
|
||||||
genesisBlock: false,
|
geth_bin: 'geth',
|
||||||
geth_bin: 'geth',
|
datadir: false,
|
||||||
datadir: false,
|
mineWhenNeeded: false,
|
||||||
mineWhenNeeded: false,
|
rpcHost: 'localhost',
|
||||||
rpcHost: 'localhost',
|
rpcPort: 8545,
|
||||||
rpcPort: 8545,
|
rpcApi: ['eth', 'web3', 'net'],
|
||||||
rpcApi: ['eth', 'web3', 'net'],
|
rpcCorsDomain: false,
|
||||||
rpcCorsDomain: false,
|
networkId: 12301,
|
||||||
networkId: 12301,
|
port: 30303,
|
||||||
port: 30303,
|
nodiscover: false,
|
||||||
nodiscover: false,
|
maxpeers: 25,
|
||||||
maxpeers: 25,
|
mine: false,
|
||||||
mine: false,
|
vmdebug: false,
|
||||||
vmdebug: false,
|
whisper: true,
|
||||||
whisper: true,
|
account: {},
|
||||||
account: {},
|
bootnodes: ""
|
||||||
bootnodes: "",
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
let blockchain = new Blockchain(config, 'geth');
|
let blockchain = new Blockchain(config, 'geth');
|
||||||
|
|
||||||
assert.deepEqual(blockchain.config, config);
|
assert.deepEqual(blockchain.config, config);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with config', function() {
|
describe('with config', function () {
|
||||||
it('should take config params', function() {
|
it('should take config params', function () {
|
||||||
let config = {
|
let config = {
|
||||||
networkType: 'livenet',
|
networkType: 'livenet',
|
||||||
genesisBlock: 'foo/bar/genesis.json',
|
genesisBlock: 'foo/bar/genesis.json',
|
||||||
|
|
Loading…
Reference in New Issue