2016-10-14 11:01:54 +00:00
|
|
|
/*globals describe, it*/
|
2018-10-06 16:05:37 +00:00
|
|
|
const Blockchain = require('../lib/modules/blockchain_process/blockchain.js');
|
2018-06-11 20:26:32 +00:00
|
|
|
const constants = require('../lib/constants.json');
|
2018-07-26 18:01:22 +00:00
|
|
|
const {defaultHost} = require('../lib/utils/host');
|
2017-03-30 11:48:22 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
const assert = require('assert');
|
2015-07-03 12:53:42 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
describe('embark.Blockchain', function() {
|
2016-10-14 11:01:54 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
describe('#initializer', function() {
|
2016-10-14 11:01:54 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
describe('with empty config', function() {
|
|
|
|
it('should have a default config', function(done) {
|
|
|
|
let blockchain = new Blockchain({});
|
|
|
|
let expectedConfig = {
|
2017-03-30 11:48:22 +00:00
|
|
|
networkType: 'custom',
|
|
|
|
genesisBlock: false,
|
2018-10-06 16:05:37 +00:00
|
|
|
ethereumClientName: 'geth',
|
|
|
|
ethereumClientBin: 'geth',
|
2017-03-30 11:48:22 +00:00
|
|
|
datadir: false,
|
|
|
|
mineWhenNeeded: false,
|
2018-07-26 18:01:22 +00:00
|
|
|
rpcHost: defaultHost,
|
2017-03-30 11:48:22 +00:00
|
|
|
rpcPort: 8545,
|
2018-10-30 21:04:38 +00:00
|
|
|
rpcApi: ['eth', 'web3', 'net', 'debug', "personal"],
|
2017-03-30 11:48:22 +00:00
|
|
|
rpcCorsDomain: false,
|
2018-10-06 16:05:37 +00:00
|
|
|
networkId: 1337,
|
2017-03-30 11:48:22 +00:00
|
|
|
port: 30303,
|
|
|
|
nodiscover: false,
|
|
|
|
maxpeers: 25,
|
|
|
|
mine: false,
|
|
|
|
vmdebug: false,
|
|
|
|
whisper: true,
|
|
|
|
account: {},
|
2018-10-06 16:05:37 +00:00
|
|
|
devPassword: "",
|
2017-10-19 23:16:08 +00:00
|
|
|
bootnodes: "",
|
2018-10-30 21:04:38 +00:00
|
|
|
wsApi: ["eth", "web3", "net", "shh", "debug", "pubsub", "personal"],
|
2018-07-26 18:01:22 +00:00
|
|
|
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-06-15 20:40:27 +00:00
|
|
|
syncMode: undefined,
|
2018-06-11 20:26:32 +00:00
|
|
|
verbosity: undefined,
|
2018-10-06 16:05:37 +00:00
|
|
|
proxy: true,
|
|
|
|
silent: undefined
|
2017-03-30 11:48:22 +00:00
|
|
|
};
|
2018-10-06 16:05:37 +00:00
|
|
|
// We check also proxy's ports because proxy is set to true
|
|
|
|
expectedConfig.wsPort += constants.blockchain.servicePortOnProxy;
|
|
|
|
expectedConfig.rpcPort += constants.blockchain.servicePortOnProxy;
|
2016-10-14 11:01:54 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
assert.deepEqual(blockchain.config, expectedConfig);
|
2017-03-30 13:16:46 +00:00
|
|
|
done();
|
2016-10-14 11:01:54 +00:00
|
|
|
});
|
2015-07-03 12:53:42 +00:00
|
|
|
});
|
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
describe('with config', function() {
|
|
|
|
it('should take config params', function(done) {
|
2017-03-29 17:57:22 +00:00
|
|
|
let config = {
|
2016-10-14 11:01:54 +00:00
|
|
|
networkType: 'livenet',
|
|
|
|
genesisBlock: 'foo/bar/genesis.json',
|
2018-10-06 16:05:37 +00:00
|
|
|
ethereumClientName: 'parity',
|
|
|
|
ethereumClientBin: 'parity',
|
2016-10-14 11:01:54 +00:00
|
|
|
datadir: '/foo/datadir/',
|
|
|
|
mineWhenNeeded: true,
|
2018-07-26 18:01:22 +00:00
|
|
|
rpcHost: defaultHost,
|
2016-10-14 11:01:54 +00:00
|
|
|
rpcPort: 12345,
|
2018-10-30 21:04:38 +00:00
|
|
|
rpcApi: ['eth', 'web3', 'net', 'debug', "personal"],
|
2016-10-14 11:01:54 +00:00
|
|
|
rpcCorsDomain: true,
|
|
|
|
networkId: 1,
|
|
|
|
port: 123456,
|
|
|
|
nodiscover: true,
|
2016-10-31 00:35:11 +00:00
|
|
|
maxpeers: 25,
|
2016-10-14 11:01:54 +00:00
|
|
|
mine: true,
|
2017-02-18 13:41:18 +00:00
|
|
|
vmdebug: false,
|
2016-10-14 11:01:54 +00:00
|
|
|
whisper: false,
|
2017-02-18 13:24:23 +00:00
|
|
|
account: {},
|
2018-10-06 16:05:37 +00:00
|
|
|
devPassword: "foo/bar/devpassword",
|
2017-10-19 23:16:08 +00:00
|
|
|
bootnodes: "",
|
2018-10-30 21:04:38 +00:00
|
|
|
wsApi: ["eth", "web3", "net", "shh", "debug", "personal"],
|
2018-07-26 18:01:22 +00:00
|
|
|
wsHost: defaultHost,
|
2017-10-19 23:16:08 +00:00
|
|
|
wsOrigins: false,
|
2018-07-26 18:01:22 +00:00
|
|
|
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,
|
2018-06-11 20:26:32 +00:00
|
|
|
verbosity: undefined,
|
|
|
|
proxy: true
|
2016-10-14 11:01:54 +00:00
|
|
|
};
|
2018-10-06 16:05:37 +00:00
|
|
|
let blockchain = new Blockchain(config);
|
2016-10-14 11:01:54 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
let expectedConfig = {
|
|
|
|
networkType: 'livenet',
|
|
|
|
genesisBlock: 'foo/bar/genesis.json',
|
|
|
|
ethereumClientName: 'parity',
|
|
|
|
ethereumClientBin: 'parity',
|
|
|
|
datadir: '/foo/datadir/',
|
|
|
|
mineWhenNeeded: true,
|
|
|
|
rpcHost: defaultHost,
|
|
|
|
rpcPort: 12345,
|
2018-10-30 21:04:38 +00:00
|
|
|
rpcApi: ['eth', 'web3', 'net', 'debug', 'personal'],
|
2018-10-06 16:05:37 +00:00
|
|
|
rpcCorsDomain: true,
|
|
|
|
networkId: 1,
|
|
|
|
port: 123456,
|
|
|
|
nodiscover: true,
|
|
|
|
maxpeers: 25,
|
|
|
|
mine: true,
|
|
|
|
vmdebug: false,
|
|
|
|
whisper: false,
|
|
|
|
account: {},
|
|
|
|
devPassword: "foo/bar/devpassword",
|
|
|
|
bootnodes: "",
|
2018-10-30 21:04:38 +00:00
|
|
|
wsApi: ["eth", "web3", "net", "shh", "debug", "personal"],
|
2018-10-06 16:05:37 +00:00
|
|
|
wsHost: defaultHost,
|
|
|
|
wsOrigins: false,
|
|
|
|
wsPort: 12346,
|
|
|
|
wsRPC: true,
|
|
|
|
targetGasLimit: false,
|
|
|
|
syncMode: undefined,
|
|
|
|
verbosity: undefined,
|
|
|
|
proxy: true,
|
|
|
|
silent: undefined
|
|
|
|
};
|
|
|
|
// We check also proxy's ports because proxy is set to true
|
|
|
|
expectedConfig.wsPort += constants.blockchain.servicePortOnProxy;
|
|
|
|
expectedConfig.rpcPort += constants.blockchain.servicePortOnProxy;
|
2018-06-11 20:26:32 +00:00
|
|
|
|
2018-10-06 16:05:37 +00:00
|
|
|
assert.deepEqual(blockchain.config, expectedConfig);
|
2017-03-30 13:16:46 +00:00
|
|
|
done();
|
2015-07-03 12:53:42 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-10-14 11:01:54 +00:00
|
|
|
});
|
2015-07-03 12:53:42 +00:00
|
|
|
});
|