From 9ed162bc26fdc0f8e254ee9dc0c3f99d4d09618d Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 31 Jul 2018 10:16:56 +0100 Subject: [PATCH] Change connection --- lib/tests/test.js | 52 +++++++++---------- .../test_app/test/another_storage_spec.js | 5 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 7ad6c019..f370dd4f 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -177,28 +177,26 @@ class Test { checkDeploymentOptions(options, callback) { const self = this; - self.simOptions = {}; - let resetServices = false; - if (options.deployment) { - if (options.deployment.accounts) { - // Account setup - self.simOptions.accounts = AccountParser.parseAccountsConfig(options.deployment.accounts, self.web3); - resetServices = true; - } - if (options.deployment.host && options.deployment.port && options.deployment.type) { - if (options.deployment.type !== 'rpc' && options.deployment.type !== 'ws') { - callback(__("contracts config error: unknown deployment type %s", options.deployment.type)); - } - Object.assign(self.simOptions, { - host: options.deployment.host, - port: options.deployment.port, - type: options.deployment.type - }); - resetServices = true; - } + self.resetServices = false; + const {host, port, type, accounts} = options.deployment || {}; + + if (host && port && !['rpc', 'ws'].includes(type)) { + callback(__("contracts config error: unknown deployment type %s", type)); } - if (!resetServices && !self.firstRunConfig) { + if(accounts || port !== this.simOptions.port || type !== this.simOptions.type || host !== this.simOptions.host) { + self.resetServices = true; + } + if (accounts) { + self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, self.web3); + } + Object.assign(self.simOptions, { + host, + port, + type + }); + + if (!self.resetServices && !self.firstRunConfig) { return callback(); } @@ -231,14 +229,8 @@ class Test { function checkDeploymentOpts(next) { self.checkDeploymentOptions(options, next); }, - function resetContracts(next) { - self.engine.contractsManager.contracts = cloneDeep(self.builtContracts); - self.engine.contractsManager.compiledContracts = cloneDeep(self.compiledContracts); - self.engine.contractsManager.contractDependencies = {}; - next(); - }, function compileContracts(next) { - if (Object.keys(self.builtContracts).length > 0) { + if (Object.keys(self.builtContracts).length > 0 && !self.resetServices) { return next(); } console.info('Compiling contracts'.cyan); @@ -252,6 +244,12 @@ class Test { next(); }); }, + function resetContracts(next) { + self.engine.contractsManager.contracts = cloneDeep(self.builtContracts); + self.engine.contractsManager.compiledContracts = cloneDeep(self.compiledContracts); + self.engine.contractsManager.contractDependencies = {}; + next(); + }, function deploy(next) { self._deploy(options, (err, accounts) => { if (err) { diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index c054c353..fa592438 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -12,7 +12,10 @@ config({ "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", balance: "5ether" } - ] + ], + "host": "localhost", + "port": 8545, + "type": "rpc" }, contracts: { "SimpleStorage": {