fix tests

This commit is contained in:
Jonathan Rainville 2018-05-23 09:54:13 -04:00
parent 6145c0b92c
commit 871c2fb228
1 changed files with 7 additions and 1 deletions

View File

@ -17,12 +17,14 @@ class Blockchain {
this.blockchainConfig = options.blockchainConfig; this.blockchainConfig = options.blockchainConfig;
this.web3 = options.web3; this.web3 = options.web3;
this.addCheck = options.addCheck; this.addCheck = options.addCheck;
this.web3Endpoint = 'http://' + this.contractsConfig.deployment.host + ':' + this.contractsConfig.deployment.port; this.web3Endpoint = '';
this.isWeb3Ready = false; this.isWeb3Ready = false;
this.web3StartedInProcess = false; this.web3StartedInProcess = false;
if (!this.web3) { if (!this.web3) {
this.initWeb3(); this.initWeb3();
} else {
this.isWeb3Ready = true;
} }
this.registerServiceCheck(); this.registerServiceCheck();
this.registerRequests(); this.registerRequests();
@ -40,6 +42,7 @@ class Blockchain {
this.web3 = new Web3(); this.web3 = new Web3();
if (this.contractsConfig.deployment.type === "rpc") { if (this.contractsConfig.deployment.type === "rpc") {
let provider; let provider;
this.web3Endpoint = 'http://' + this.contractsConfig.deployment.host + ':' + this.contractsConfig.deployment.port;
const providerOptions = { const providerOptions = {
web3: this.web3, web3: this.web3,
@ -224,6 +227,9 @@ class Blockchain {
next(); next();
}, },
function pingEndpoint(next) { function pingEndpoint(next) {
if (!self.web3Endpoint) {
return next();
}
request.get(self.web3Endpoint, function (err, _response, _body) { request.get(self.web3Endpoint, function (err, _response, _body) {
if (err) { if (err) {
return next(NO_NODE_ERROR); return next(NO_NODE_ERROR);