mirror of https://github.com/embarklabs/embark.git
feat: add test env to embark test and disable modules by default
This commit is contained in:
parent
96d51e1aea
commit
6d0b680dc5
|
@ -1,9 +1,7 @@
|
|||
{
|
||||
module.exports = {
|
||||
"default": {
|
||||
"enabled": true,
|
||||
"available_providers": [
|
||||
"ens"
|
||||
],
|
||||
"available_providers": ["ens"],
|
||||
"provider": "ens",
|
||||
"register": {
|
||||
"rootDomain": "embark.eth",
|
||||
|
@ -13,5 +11,8 @@
|
|||
"MyToken2": "$MyToken2"
|
||||
}
|
||||
}
|
||||
},
|
||||
test: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
};
|
|
@ -11,7 +11,7 @@ module.exports = function (embark) {
|
|||
|
||||
embark.registerContractConfiguration({
|
||||
"default": {
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"PluginStorage": {
|
||||
"args": ["$SimpleStorage"]
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ class Cmd {
|
|||
test() {
|
||||
program
|
||||
.command('test [file]')
|
||||
.option('-e, --env <env>', __('configuration environment to use (default: development)'))
|
||||
.option('-e, --env <env>', __('configuration environment to use (default: test)'))
|
||||
.option('-n , --node <node>', __('node for running the tests ["vm", "embark", <endpoint>] (default: vm)\n') +
|
||||
' vm - ' + __('start and use an Ethereum simulator (ganache)') + '\n' +
|
||||
' embark - ' + __('use the node of a running embark process') + '\n' +
|
||||
|
@ -279,7 +279,7 @@ class Cmd {
|
|||
txDetails: options.txDetails,
|
||||
node: options.node,
|
||||
coverage: options.coverage,
|
||||
env: options.env || 'development'
|
||||
env: options.env || 'test'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -251,7 +251,11 @@ Config.prototype._doMergeConfig = function(config, defaultConfig, env) {
|
|||
let configObject = recursiveMerge(defaultConfig, config);
|
||||
|
||||
if (env) {
|
||||
return recursiveMerge(configObject['default'] || {}, configObject[env]);
|
||||
if (env === 'test' && !configObject[env]) {
|
||||
// Disabled all configs in tests as they are opt in
|
||||
return Object.assign({}, defaultConfig.default, {enabled: false});
|
||||
}
|
||||
return recursiveMerge(configObject.default || {}, configObject[env]);
|
||||
} else if (env !== false) {
|
||||
this.logger.warn(__("No environment called %s found. Using defaults.", env));
|
||||
}
|
||||
|
@ -279,6 +283,10 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
|||
const envConfig = userConfig[this.env];
|
||||
|
||||
if (envConfig) {
|
||||
if (envConfig.ethereumClientName || envConfig.hasOwnProperty('isDev') || envConfig.hasOwnProperty('mineWhenNeeded')) {
|
||||
this.logger.error(__('The blockchain config has changed quite a bit in Embark 5\nPlease visit %s to know what has to be changed', embark5ChangesUrl.underline));
|
||||
process.exit(1);
|
||||
}
|
||||
if (envConfig.clientConfig) {
|
||||
Object.assign(envConfig, envConfig.clientConfig);
|
||||
delete envConfig.clientConfig;
|
||||
|
@ -312,11 +320,6 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
|||
|
||||
this.blockchainConfig = this._doMergeConfig(userConfig, blockchainDefaults, this.env);
|
||||
|
||||
if (this.blockchainConfig.ethereumClientName || this.blockchainConfig.isDev || this.blockchainConfig.mineWhenNeeded) {
|
||||
this.logger.error(__('The blockchain config has changed quite a bit in Embark 5\nPlease visit %s to know what has to be changed', embark5ChangesUrl.underline));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!configFilePath) {
|
||||
this.blockchainConfig.default = true;
|
||||
}
|
||||
|
|
|
@ -3,33 +3,34 @@ import {recursiveMerge} from "embark-utils";
|
|||
const constants = require('embark-core/constants');
|
||||
|
||||
export function getBlockchainDefaults(env) {
|
||||
const defaults = {
|
||||
enabled: true,
|
||||
client: constants.blockchain.clients.geth,
|
||||
proxy: true,
|
||||
datadir: `.embark/${env}/datadir`,
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: {
|
||||
auto: true,
|
||||
additionalCors: []
|
||||
},
|
||||
wsRPC: true,
|
||||
wsOrigins: {
|
||||
auto: true,
|
||||
additionalCors: []
|
||||
},
|
||||
wsHost: "localhost",
|
||||
wsPort: 8546,
|
||||
networkType: "custom",
|
||||
miningMode: 'dev',
|
||||
nodiscover: true,
|
||||
maxpeers: 0,
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
};
|
||||
return {
|
||||
default: {
|
||||
enabled: true,
|
||||
client: constants.blockchain.clients.geth,
|
||||
proxy: true,
|
||||
datadir: `.embark/${env}/datadir`,
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: {
|
||||
auto: true,
|
||||
additionalCors: []
|
||||
},
|
||||
wsRPC: true,
|
||||
wsOrigins: {
|
||||
auto: true,
|
||||
additionalCors: []
|
||||
},
|
||||
wsHost: "localhost",
|
||||
wsPort: 8546,
|
||||
networkType: "custom",
|
||||
isDev: false,
|
||||
mineWhenNeeded: false,
|
||||
nodiscover: true,
|
||||
maxpeers: 0,
|
||||
targetGasLimit: 8000000,
|
||||
simulatorBlocktime: 0
|
||||
}
|
||||
default: defaults,
|
||||
test: defaults
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ Typically this call is used in combination with `embark.addContractFile`
|
|||
module.exports = function(embark) {
|
||||
embark.registerContractConfiguration({
|
||||
"default": {
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"DGDToken": {
|
||||
"args": [
|
||||
100
|
||||
|
@ -75,7 +75,7 @@ module.exports = function(embark) {
|
|||
}
|
||||
},
|
||||
"livenet": {
|
||||
"contracts": {
|
||||
"deploy": {
|
||||
"DGDToken": {
|
||||
"address": "0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue