embark/test/blockchain.js

105 lines
3.0 KiB
JavaScript
Raw Normal View History

/*globals describe, it*/
2017-03-30 11:12:39 +00:00
const Blockchain = require('../lib/cmds/blockchain/blockchain');
2018-06-11 20:26:32 +00:00
const constants = require('../lib/constants.json');
const {defaultHost} = require('../lib/utils/host');
2017-03-30 11:12:39 +00:00
const assert = require('assert');
2015-07-03 12:53:42 +00:00
describe('embark.Blockchain', function () {
2017-03-29 17:57:22 +00:00
//let Client = function() {};
//Client.prototype.name = "ClientName";
describe('#initializer', function () {
2017-03-29 17:57:22 +00:00
//let client = new Client();
describe('with empty config', function () {
2017-03-30 13:16:46 +00:00
it('should have a default config', function (done) {
2017-03-29 17:57:22 +00:00
let config = {
networkType: 'custom',
genesisBlock: false,
geth_bin: 'geth',
datadir: false,
mineWhenNeeded: false,
rpcHost: defaultHost,
rpcPort: 8545,
2018-06-18 13:44:16 +00:00
rpcApi: ['eth', 'web3', 'net', 'debug'],
rpcCorsDomain: false,
networkId: 12301,
port: 30303,
nodiscover: false,
maxpeers: 25,
mine: false,
vmdebug: false,
whisper: true,
account: {},
2017-10-19 23:16:08 +00:00
bootnodes: "",
2018-06-18 13:44:16 +00:00
wsApi: ["eth", "web3", "net", "shh", "debug"],
wsHost: defaultHost,
2017-10-19 23:16:08 +00:00
wsOrigins: false,
2018-01-12 19:21:46 +00:00
wsPort: 8546,
2018-01-17 16:29:30 +00:00
wsRPC: true,
2018-01-24 00:36:02 +00:00
targetGasLimit: false,
2018-07-05 12:37:11 +00:00
syncmode: undefined,
2018-06-15 20:40:27 +00:00
syncMode: undefined,
syncmode: undefined,
2018-06-11 20:26:32 +00:00
verbosity: undefined,
proxy: true
};
let blockchain = new Blockchain(config, 'geth');
2018-06-11 20:26:32 +00:00
if(config.proxy){
config.wsPort += constants.blockchain.servicePortOnProxy;
config.rpcPort += constants.blockchain.servicePortOnProxy;
}
assert.deepEqual(blockchain.config, config);
2017-03-30 13:16:46 +00:00
done();
});
2015-07-03 12:53:42 +00:00
});
describe('with config', function () {
2017-03-30 13:16:46 +00:00
it('should take config params', function (done) {
2017-03-29 17:57:22 +00:00
let config = {
networkType: 'livenet',
genesisBlock: 'foo/bar/genesis.json',
2017-02-18 13:55:33 +00:00
geth_bin: 'geth',
datadir: '/foo/datadir/',
mineWhenNeeded: true,
rpcHost: defaultHost,
rpcPort: 12345,
2018-06-18 13:44:16 +00:00
rpcApi: ['eth', 'web3', 'net', 'debug'],
rpcCorsDomain: true,
networkId: 1,
port: 123456,
nodiscover: true,
2016-10-31 00:35:11 +00:00
maxpeers: 25,
mine: true,
2017-02-18 13:41:18 +00:00
vmdebug: false,
whisper: false,
2017-02-18 13:24:23 +00:00
account: {},
2017-10-19 23:16:08 +00:00
bootnodes: "",
2018-06-18 13:44:16 +00:00
wsApi: ["eth", "web3", "net", "shh", "debug"],
wsHost: defaultHost,
2017-10-19 23:16:08 +00:00
wsOrigins: false,
wsPort: 12346,
2018-01-17 16:29:30 +00:00
wsRPC: true,
2018-01-24 00:36:02 +00:00
targetGasLimit: false,
2018-06-15 20:40:27 +00:00
syncMode: undefined,
syncmode: undefined,
2018-06-11 20:26:32 +00:00
verbosity: undefined,
proxy: true
};
let blockchain = new Blockchain(config, 'geth');
2018-06-11 20:26:32 +00:00
if(config.proxy){
config.wsPort += constants.blockchain.servicePortOnProxy;
config.rpcPort += constants.blockchain.servicePortOnProxy;
}
assert.deepEqual(blockchain.config, config);
2017-03-30 13:16:46 +00:00
done();
2015-07-03 12:53:42 +00:00
});
});
});
2015-07-03 12:53:42 +00:00
});