embark-area-51/test/config.blockchain.js

130 lines
3.4 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',
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: "*",
minerthreads: 1,
genesisBlock: 'config/genesis.json',
2015-06-28 13:51:58 +00:00
datadir: '/tmp/embark',
networkId: 0,
2015-07-30 01:40:49 +00:00
maxPeers: 4,
2015-06-28 13:51:58 +00:00
port: "30303",
console_toggle: false,
mine_when_needed: true,
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',
mine_when_needed: true,
console: false,
account: {
init: true,
password: 'config/password'
}
},
staging: {}
};
blockchainConfig.loadConfig(hsh);
assert.deepEqual(blockchainConfig.config('development'), {
rpcHost: 'localhost',
rpcPort: 8101,
gasLimit: 500000,
gasPrice: 10000000000000,
rpcWhitelist: "*",
minerthreads: 1,
genesisBlock: undefined,
2015-06-28 13:51:58 +00:00
datadir: '/tmp/embark',
networkId: 0,
2015-07-30 01:40:49 +00:00
maxPeers: 4,
2015-06-28 13:51:58 +00:00
port: "30303",
console_toggle: false,
mine_when_needed: true,
account: {
init: true,
password: 'config/password'
}
})
});
it('should load environment', function() {
var blockchainConfig = new Config.Blockchain();
assert.throws(function() { blockchainConfig.config('development') }, Error);
});
});
});