mirror of https://github.com/embarklabs/embark.git
126 lines
3.3 KiB
JavaScript
126 lines
3.3 KiB
JavaScript
|
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,
|
||
|
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,
|
||
|
datadir: '/tmp/embark',
|
||
|
networkId: 0,
|
||
|
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,
|
||
|
datadir: '/tmp/embark',
|
||
|
networkId: 0,
|
||
|
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);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|