<commit_before>var async = require('async');
var Web3 = require('web3');
var Embark = require('./index.js');
var ContractsManager = require('./contracts.js');
var Deploy = require('./deploy.js');
var TestLogger = require('./test_logger.js');
var Config = require('./config.js');
var ABIGenerator = require('./abi.js');

var Test = function(options) {

  try {
    this.sim = require('ethereumjs-testrpc');
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND') {
      console.log('Simulator not found; Please install it with "npm install ethereumjs-testrpc --save"');
      console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save"');
      console.log('For more information see https://github.com/ethereumjs/testrpc');
      exit();
    } else {
      console.log("==============");
      console.log("Tried to load testrpc but an error occurred. This is a problem with testrpc");
      console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save". Alternatively install node 6.9.1 and the testrpc 3.0');
      console.log("==============");
      throw e;
    }
  }

  this.web3 = new Web3();
  this.web3.setProvider(this.sim.provider());
};

Test.prototype.deployAll = function(contractsConfig, cb) {
  var self = this;
  var logger = new TestLogger({logLevel: 'debug'});

  async.waterfall([
      function getConfig(callback) {
        var config = new Config({env: 'test', logger: logger});
        config.loadConfigFiles({embarkConfig: 'embark.json', interceptLogs: false});
        config.contractsConfig = {contracts: contractsConfig};
        callback(null, config);
      },
      function buildContracts(config, callback) {
        var contractsManager = new ContractsManager({
          contractFiles:  config.contractsFiles,
          contractsConfig: config.contractsConfig,
          logger: logger,
          plugins: config.plugins
        });
        contractsManager.build(function() {
          callback(null, contractsManager);
        });
      },
      function deployContracts(contractsManager, callback) {
        var deploy = new Deploy({
          web3: self.web3,
          contractsManager: contractsManager,
          logger: logger,<commit_msg>support configuring simulator in the tests<commit_after>var async = require('async');
var Web3 = require('web3');
var Embark = require('./index.js');
var ContractsManager = require('./contracts.js');
var Deploy = require('./deploy.js');
var TestLogger = require('./test_logger.js');
var Config = require('./config.js');
var ABIGenerator = require('./abi.js');

var Test = function(_options) {
  var options = _options || {};
  var simOptions = options.simulatorOptions || {};

  try {
    this.sim = require('ethereumjs-testrpc');
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND') {
      console.log('Simulator not found; Please install it with "npm install ethereumjs-testrpc --save"');
      console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save"');
      console.log('For more information see https://github.com/ethereumjs/testrpc');
      exit();
    } else {
      console.log("==============");
      console.log("Tried to load testrpc but an error occurred. This is a problem with testrpc");
      console.log('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "npm install ethereumjs-testrpc@2.0 --save". Alternatively install node 6.9.1 and the testrpc 3.0');
      console.log("==============");
      throw e;
    }
  }

  this.web3 = new Web3();
  this.web3.setProvider(this.sim.provider(simOptions));
};

Test.prototype.deployAll = function(contractsConfig, cb) {
  var self = this;
  var logger = new TestLogger({logLevel: 'debug'});

  async.waterfall([
      function getConfig(callback) {
        var config = new Config({env: 'test', logger: logger});
        config.loadConfigFiles({embarkConfig: 'embark.json', interceptLogs: false});
        config.contractsConfig = {contracts: contractsConfig};
        callback(null, config);
      },
      function buildContracts(config, callback) {
        var contractsManager = new ContractsManager({
          contractFiles:  config.contractsFiles,
          contractsConfig: config.contractsConfig,
          logger: logger,
          plugins: config.plugins
        });
        contractsManager.build(function() {
          callback(null, contractsManager);
        });
      },
      function deployContracts(contractsManager, callback) {
        var deploy = new Deploy({
          web3: self.web3,
          contractsManager: contractsManager,
          logger: logger,
{'fraction_non_alphanumeric': 0.13826104663001426, 'fraction_numerical': 0.008959478721238036, 'mean_word_length': 3.209083119108826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '285527', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1383, 'n_words': 394}