From a322d0305395937df402639a8dbd1334a70ad3d0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 15 Jan 2018 09:51:45 -0500 Subject: [PATCH] support external node in tests --- lib/core/run_tests.js | 2 ++ lib/core/test.js | 11 ++++++++--- test_app/test/simple_storage_spec.js | 7 +++++++ test_app/test/token_spec.js | 7 +++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/core/run_tests.js b/lib/core/run_tests.js index 9d3010fbb..5ac47a005 100644 --- a/lib/core/run_tests.js +++ b/lib/core/run_tests.js @@ -50,6 +50,8 @@ module.exports = { }; // TODO: check how to pass the options //global.EmbarkSpec = new Test(options); + + // TODO: this global here might not be necessary at all global.EmbarkSpec = new Test({}); global.web3 = global.EmbarkSpec.web3; diff --git a/lib/core/test.js b/lib/core/test.js index 3ff9bc767..dd53cb585 100644 --- a/lib/core/test.js +++ b/lib/core/test.js @@ -29,7 +29,7 @@ var getSimulator = function() { var Test = function(options) { this.options = options || {}; - var simOptions = this.options.simulatorOptions || {}; + this.simOptions = this.options.simulatorOptions || {}; this.engine = new Engine({ env: this.options.env || 'test', @@ -42,14 +42,19 @@ var Test = function(options) { logger: new TestLogger({logLevel: 'debug'}) }); - this.sim = getSimulator(); this.web3 = new Web3(); - this.web3.setProvider(this.sim.provider(simOptions)); }; Test.prototype.deployAll = function(contractsConfig, cb) { var self = this; + if (this.simOptions.node) { + this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); + } else { + this.sim = getSimulator(); + this.web3.setProvider(this.sim.provider(this.simOptions)); + } + async.waterfall([ function getConfig(callback) { let _versions_default = self.engine.config.contractsConfig.versions; diff --git a/test_app/test/simple_storage_spec.js b/test_app/test/simple_storage_spec.js index 9459cfa42..4e990431a 100644 --- a/test_app/test/simple_storage_spec.js +++ b/test_app/test/simple_storage_spec.js @@ -1,7 +1,14 @@ + contract("SimpleStorage", function() { + this.timeout(0); before(function(done) { this.timeout(0); + + config({ + node: "http://localhost:8545" + }); + var contractsConfig = { "SimpleStorage": { args: [100] diff --git a/test_app/test/token_spec.js b/test_app/test/token_spec.js index 4f5c64176..9974dbabf 100644 --- a/test_app/test/token_spec.js +++ b/test_app/test/token_spec.js @@ -1,7 +1,14 @@ + describe("Token", function() { + this.timeout(0); before(function(done) { this.timeout(0); + + //config({ + // node: "http://localhost:8545" + //}); + var contractsConfig = { "SimpleStorage": { args: [100]