diff --git a/lib/modules/blockchain_connector/index.js b/lib/modules/blockchain_connector/index.js index 4e95cdec..28f2a0c3 100644 --- a/lib/modules/blockchain_connector/index.js +++ b/lib/modules/blockchain_connector/index.js @@ -105,6 +105,7 @@ class BlockchainConnector { .catch(console.error); self.provider.fundAccounts(() => { self._emitWeb3Ready(); + cb(); }); }); }); diff --git a/lib/modules/tests/test.js b/lib/modules/tests/test.js index a033760a..b7f958e4 100644 --- a/lib/modules/tests/test.js +++ b/lib/modules/tests/test.js @@ -1,11 +1,5 @@ const async = require('async'); -// const Engine = require('../../core/engine.js'); -// const TestLogger = require('./test_logger.js'); -// const Web3 = require('web3'); const AccountParser = require('../../utils/accountParser'); -// TODO: breaks module isolation; tests need to be refactored to use the engine and avoid this -const Provider = require('../blockchain_connector/provider.js'); -const utils = require('../../utils/utils'); class Test { constructor(options) { @@ -23,13 +17,6 @@ class Test { this.blockchainConnector = null; this.provider = null; this.accounts = []; - - /*this.engine = new Engine({ - env: this.options.env || 'test', - // TODO: config will need to detect if this is a obj - embarkConfig: this.options.embarkConfig || 'embark.json', - interceptLogs: false - });*/ } init(callback) { @@ -39,47 +26,9 @@ class Test { this.blockchainConnector = connector; callback(); }); - - /*let self = this; - async.waterfall([ - function initEngine(cb) { - self.engine.init({ - logger: new TestLogger({logLevel: self.options.loglevel}) - }, cb); - }, - function startServices(cb) { - self.versions_default = self.engine.config.contractsConfig.versions; - // Reset contract config to nothing to make sure we deploy only what we want - self.engine.config.contractsConfig = { - contracts: {}, - versions: self.versions_default - }; - - self.engine.startService("libraryManager"); - self.engine.startService("codeRunner"); - self.initDeployServices(); - self.engine.startService("codeGenerator"); - self.engine.startService("codeCoverage"); - - if (self.options.node === 'embark') { - if (!self.engine.ipc.connected) { - self.engine.logger.error("Could not connect to Embark's IPC. Is embark running?"); - process.exit(1); - } - return self.connectToIpcNode(cb); - } - self.showNodeHttpWarning(); - cb(); - } - ], callback);*/ } initWeb3Provider(callback) { - const self = this; - if (this.provider) { - this.provider.stop(); - } - if (this.simOptions.accounts) { this.simOptions.accounts = this.simOptions.accounts.map((account) => { if (!account.hexBalance) { @@ -90,7 +39,7 @@ class Test { } // TODO use event for this - if (!this.simOptions.host || (this.options.node && this.options.node === 'vm')) { + if (!this.simOptions.host && (this.options.node && this.options.node === 'vm')) { this.simOptions.type = 'vm'; } this.configObj.contractsConfig.deployment = this.simOptions; @@ -98,51 +47,6 @@ class Test { this.blockchainConnector.isWeb3Ready = false; this.blockchainConnector.wait = false; - // TODO change this - if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) { - let options = this.simOptions; - if (this.options.node) { - options = utils.deconstructUrl(this.options.node); - } - - let {host, port, type, protocol, accounts} = options; - if (!protocol) { - protocol = (options.type === "rpc") ? 'http' : 'ws'; - } - const endpoint = `${protocol}://${host}:${port}`; - const providerOptions = { - web3: this.web3, - type, - accountsConfig: accounts, - blockchainConfig: this.configObj.blockchainConfig, - logger: this.logger, - isDev: false, - web3Endpoint: endpoint - }; - self.logger.info(`Connecting to node at ${endpoint}`.cyan); - - return utils.pingEndpoint(host, port, type, protocol, this.configObj.blockchainConfig.wsOrigins.split(',')[0], (err) => { - if (err) { - self.logger.error(`Error connecting to the node, there might be an error in ${endpoint}`.red); - return callback(err); - } - - self.provider = new Provider(providerOptions); - return self.provider.startWeb3Provider((err) => { - if (err) { - return callback(err); - } - callback(); - }); - }); - } - - // if (!this.sim) { - // this.sim = getSimulator(); - // } - - // let simProvider = this.sim.provider(this.simOptions); - // TODO change this /*if (this.options.coverage) { // Here we patch the sendAsync method on the provider. The goal behind this is to force pure/constant/view calls to become @@ -180,8 +84,6 @@ class Test { }*/ this.blockchainConnector.initWeb3(callback); - // this.web3.setProvider(simProvider); - // callback(); } /*initDeployServices() { @@ -276,7 +178,6 @@ class Test { return callback(err); } self.firstRunConfig = false; - // self.initDeployServices(); callback(); }); });