support external node in tests

This commit is contained in:
Iuri Matias 2018-01-15 09:51:45 -05:00
parent 1c77449419
commit a322d03053
4 changed files with 24 additions and 3 deletions

View File

@ -50,6 +50,8 @@ module.exports = {
}; };
// TODO: check how to pass the options // TODO: check how to pass the options
//global.EmbarkSpec = new Test(options); //global.EmbarkSpec = new Test(options);
// TODO: this global here might not be necessary at all
global.EmbarkSpec = new Test({}); global.EmbarkSpec = new Test({});
global.web3 = global.EmbarkSpec.web3; global.web3 = global.EmbarkSpec.web3;

View File

@ -29,7 +29,7 @@ var getSimulator = function() {
var Test = function(options) { var Test = function(options) {
this.options = options || {}; this.options = options || {};
var simOptions = this.options.simulatorOptions || {}; this.simOptions = this.options.simulatorOptions || {};
this.engine = new Engine({ this.engine = new Engine({
env: this.options.env || 'test', env: this.options.env || 'test',
@ -42,14 +42,19 @@ var Test = function(options) {
logger: new TestLogger({logLevel: 'debug'}) logger: new TestLogger({logLevel: 'debug'})
}); });
this.sim = getSimulator();
this.web3 = new Web3(); this.web3 = new Web3();
this.web3.setProvider(this.sim.provider(simOptions));
}; };
Test.prototype.deployAll = function(contractsConfig, cb) { Test.prototype.deployAll = function(contractsConfig, cb) {
var self = this; 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([ async.waterfall([
function getConfig(callback) { function getConfig(callback) {
let _versions_default = self.engine.config.contractsConfig.versions; let _versions_default = self.engine.config.contractsConfig.versions;

View File

@ -1,7 +1,14 @@
contract("SimpleStorage", function() { contract("SimpleStorage", function() {
this.timeout(0); this.timeout(0);
before(function(done) { before(function(done) {
this.timeout(0); this.timeout(0);
config({
node: "http://localhost:8545"
});
var contractsConfig = { var contractsConfig = {
"SimpleStorage": { "SimpleStorage": {
args: [100] args: [100]

View File

@ -1,7 +1,14 @@
describe("Token", function() { describe("Token", function() {
this.timeout(0); this.timeout(0);
before(function(done) { before(function(done) {
this.timeout(0); this.timeout(0);
//config({
// node: "http://localhost:8545"
//});
var contractsConfig = { var contractsConfig = {
"SimpleStorage": { "SimpleStorage": {
args: [100] args: [100]