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": {
|
"default": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"available_providers": [
|
"available_providers": ["ens"],
|
||||||
"ens"
|
|
||||||
],
|
|
||||||
"provider": "ens",
|
"provider": "ens",
|
||||||
"register": {
|
"register": {
|
||||||
"rootDomain": "embark.eth",
|
"rootDomain": "embark.eth",
|
||||||
|
@ -13,5 +11,8 @@
|
||||||
"MyToken2": "$MyToken2"
|
"MyToken2": "$MyToken2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
enabled: true
|
||||||
}
|
}
|
||||||
}
|
};
|
|
@ -11,7 +11,7 @@ module.exports = function (embark) {
|
||||||
|
|
||||||
embark.registerContractConfiguration({
|
embark.registerContractConfiguration({
|
||||||
"default": {
|
"default": {
|
||||||
"contracts": {
|
"deploy": {
|
||||||
"PluginStorage": {
|
"PluginStorage": {
|
||||||
"args": ["$SimpleStorage"]
|
"args": ["$SimpleStorage"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ class Cmd {
|
||||||
test() {
|
test() {
|
||||||
program
|
program
|
||||||
.command('test [file]')
|
.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') +
|
.option('-n , --node <node>', __('node for running the tests ["vm", "embark", <endpoint>] (default: vm)\n') +
|
||||||
' vm - ' + __('start and use an Ethereum simulator (ganache)') + '\n' +
|
' vm - ' + __('start and use an Ethereum simulator (ganache)') + '\n' +
|
||||||
' embark - ' + __('use the node of a running embark process') + '\n' +
|
' embark - ' + __('use the node of a running embark process') + '\n' +
|
||||||
|
@ -279,7 +279,7 @@ class Cmd {
|
||||||
txDetails: options.txDetails,
|
txDetails: options.txDetails,
|
||||||
node: options.node,
|
node: options.node,
|
||||||
coverage: options.coverage,
|
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);
|
let configObject = recursiveMerge(defaultConfig, config);
|
||||||
|
|
||||||
if (env) {
|
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) {
|
} else if (env !== false) {
|
||||||
this.logger.warn(__("No environment called %s found. Using defaults.", env));
|
this.logger.warn(__("No environment called %s found. Using defaults.", env));
|
||||||
}
|
}
|
||||||
|
@ -279,6 +283,10 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
||||||
const envConfig = userConfig[this.env];
|
const envConfig = userConfig[this.env];
|
||||||
|
|
||||||
if (envConfig) {
|
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) {
|
if (envConfig.clientConfig) {
|
||||||
Object.assign(envConfig, envConfig.clientConfig);
|
Object.assign(envConfig, envConfig.clientConfig);
|
||||||
delete envConfig.clientConfig;
|
delete envConfig.clientConfig;
|
||||||
|
@ -312,11 +320,6 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
||||||
|
|
||||||
this.blockchainConfig = this._doMergeConfig(userConfig, blockchainDefaults, this.env);
|
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) {
|
if (!configFilePath) {
|
||||||
this.blockchainConfig.default = true;
|
this.blockchainConfig.default = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,33 +3,34 @@ import {recursiveMerge} from "embark-utils";
|
||||||
const constants = require('embark-core/constants');
|
const constants = require('embark-core/constants');
|
||||||
|
|
||||||
export function getBlockchainDefaults(env) {
|
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 {
|
return {
|
||||||
default: {
|
default: defaults,
|
||||||
enabled: true,
|
test: defaults
|
||||||
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
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ Typically this call is used in combination with `embark.addContractFile`
|
||||||
module.exports = function(embark) {
|
module.exports = function(embark) {
|
||||||
embark.registerContractConfiguration({
|
embark.registerContractConfiguration({
|
||||||
"default": {
|
"default": {
|
||||||
"contracts": {
|
"deploy": {
|
||||||
"DGDToken": {
|
"DGDToken": {
|
||||||
"args": [
|
"args": [
|
||||||
100
|
100
|
||||||
|
@ -75,7 +75,7 @@ module.exports = function(embark) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"livenet": {
|
"livenet": {
|
||||||
"contracts": {
|
"deploy": {
|
||||||
"DGDToken": {
|
"DGDToken": {
|
||||||
"address": "0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"
|
"address": "0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue