diff --git a/dapps/tests/app/config/namesystem.json b/dapps/tests/app/config/namesystem.js similarity index 75% rename from dapps/tests/app/config/namesystem.json rename to dapps/tests/app/config/namesystem.js index 0ae3340be..bb7297b75 100644 --- a/dapps/tests/app/config/namesystem.json +++ b/dapps/tests/app/config/namesystem.js @@ -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 } -} +}; diff --git a/dapps/tests/service/index.js b/dapps/tests/service/index.js index a35761904..a78414d8a 100644 --- a/dapps/tests/service/index.js +++ b/dapps/tests/service/index.js @@ -11,7 +11,7 @@ module.exports = function (embark) { embark.registerContractConfiguration({ "default": { - "contracts": { + "deploy": { "PluginStorage": { "args": ["$SimpleStorage"] } diff --git a/packages/embark/src/cmd/cmd.js b/packages/embark/src/cmd/cmd.js index 7da51b7bb..bf165181c 100644 --- a/packages/embark/src/cmd/cmd.js +++ b/packages/embark/src/cmd/cmd.js @@ -243,7 +243,7 @@ class Cmd { test() { program .command('test [file]') - .option('-e, --env ', __('configuration environment to use (default: development)')) + .option('-e, --env ', __('configuration environment to use (default: test)')) .option('-n , --node ', __('node for running the tests ["vm", "embark", ] (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' }); }); } diff --git a/packages/embark/src/lib/core/config.js b/packages/embark/src/lib/core/config.js index b0696ec13..159a710aa 100644 --- a/packages/embark/src/lib/core/config.js +++ b/packages/embark/src/lib/core/config.js @@ -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; } diff --git a/packages/embark/src/lib/core/configDefaults.js b/packages/embark/src/lib/core/configDefaults.js index a86510f6a..9b8a67283 100644 --- a/packages/embark/src/lib/core/configDefaults.js +++ b/packages/embark/src/lib/core/configDefaults.js @@ -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 }; } diff --git a/site/source/docs/plugin_reference.md b/site/source/docs/plugin_reference.md index 9c806a59e..8342fb7a7 100644 --- a/site/source/docs/plugin_reference.md +++ b/site/source/docs/plugin_reference.md @@ -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" }