Change connection

This commit is contained in:
Anthony Laibe 2018-07-31 10:16:56 +01:00 committed by Iuri Matias
parent d0555fe23c
commit 9ed162bc26
2 changed files with 29 additions and 28 deletions

View File

@ -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) {

View File

@ -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": {