embark/old_test/config.blockchain.js

151 lines
4.0 KiB
JavaScript
Raw Normal View History

2015-06-28 13:51:58 +00:00
var Config = require('../lib/config/config.js');
var assert = require('assert');
describe('embark.config.blockchain', function() {
var blockchainConfig = new Config.Blockchain();
describe('#loadConfigFile', function() {
it('should read and load yml file', function() {
blockchainConfig.loadConfigFile('test/support/blockchain.yml');
assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('development'), true)
assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('staging'), true)
});
it('should throw exception reading invalid file', function() {
assert.throws(function() { blockchainConfig.loadConfigFile('test/support/invalid.yml') }, Error);
});
});
describe('#loadConfig', function() {
it('should load config', function() {
var hsh = {
development: {},
staging: {}
};
blockchainConfig.loadConfig(hsh);
assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('development'), true)
assert.equal(blockchainConfig.blockchainConfig.hasOwnProperty('staging'), true)
});
});
describe('#config', function() {
it('should load environment', function() {
var hsh = {
development: {
rpc_host: 'localhost',
rpc_port: 8101,
rpc_whitelist: "*",
network_id: 0,
minerthreads: 1,
genesis_block: 'config/genesis.json',
2015-06-28 13:51:58 +00:00
datadir: '/tmp/embark',
chains: 'chains_development.json',
deploy_timeout: 45,
2015-06-28 13:51:58 +00:00
mine_when_needed: true,
gas_limit: 123,
gas_price: 100,
console: false,
account: {
init: true,
password: 'config/password'
}
},
staging: {}
};
blockchainConfig.loadConfig(hsh);
assert.deepEqual(blockchainConfig.config('development'), {
rpcHost: 'localhost',
rpcPort: 8101,
gasLimit: 123,
gasPrice: 100,
rpcWhitelist: "*",
2015-12-06 21:02:13 +00:00
testnet: false,
bootNodes: [],
2015-08-27 13:36:22 +00:00
whisper: false,
2015-06-28 13:51:58 +00:00
minerthreads: 1,
2016-02-09 20:45:48 +00:00
nat: [],
genesisBlock: 'config/genesis.json',
2015-06-28 13:51:58 +00:00
datadir: '/tmp/embark',
chains: 'chains_development.json',
deployTimeout: 45,
2016-02-29 14:59:34 +00:00
deploy_synchronously: false,
2015-06-28 13:51:58 +00:00
networkId: 0,
2015-07-30 01:40:49 +00:00
maxPeers: 4,
2016-02-09 20:45:48 +00:00
mine: false,
2015-06-28 13:51:58 +00:00
port: "30303",
console_toggle: false,
mine_when_needed: true,
2015-12-06 21:02:13 +00:00
geth_extra_opts: [],
2015-06-28 13:51:58 +00:00
account: {
init: true,
password: 'config/password'
}
})
});
it('should return defaults', function() {
var hsh = {
development: {
rpc_host: 'localhost',
rpc_port: 8101,
rpc_whitelist: "*",
network_id: 0,
minerthreads: 1,
datadir: '/tmp/embark',
chains: undefined,
2015-06-28 13:51:58 +00:00
mine_when_needed: true,
console: false,
account: {
init: true,
password: 'config/password'
},
2015-06-28 13:51:58 +00:00
},
staging: {}
};
blockchainConfig.loadConfig(hsh);
assert.deepEqual(blockchainConfig.config('development'), {
rpcHost: 'localhost',
rpcPort: 8101,
gasLimit: 500000,
gasPrice: 10000000000000,
rpcWhitelist: "*",
2015-12-06 21:02:13 +00:00
testnet: false,
bootNodes: [],
2015-08-27 13:36:22 +00:00
whisper: false,
2015-06-28 13:51:58 +00:00
minerthreads: 1,
2016-02-09 20:45:48 +00:00
nat: [],
genesisBlock: undefined,
2015-06-28 13:51:58 +00:00
datadir: '/tmp/embark',
chains: undefined,
deployTimeout: 20,
2016-02-29 14:59:34 +00:00
deploy_synchronously: false,
2015-06-28 13:51:58 +00:00
networkId: 0,
2015-07-30 01:40:49 +00:00
maxPeers: 4,
2016-02-09 20:45:48 +00:00
mine: false,
2015-06-28 13:51:58 +00:00
port: "30303",
console_toggle: false,
mine_when_needed: true,
2015-12-06 21:02:13 +00:00
geth_extra_opts: [],
2015-06-28 13:51:58 +00:00
account: {
init: true,
password: 'config/password'
}
})
});
it('should load environment', function() {
var blockchainConfig = new Config.Blockchain();
assert.throws(function() { blockchainConfig.config('development') }, Error);
});
});
});