<commit_before>var Stex    = require("stex");
var hash    = require("../lib/util/hash")
var Promise = Stex.Promise;

var helpers = module.exports;

var clearDb = function() {
  return db.raw("TRUNCATE TABLE wallets");
}

var makeWallet = function(params) {
  return Promise
    .props({ 
      id:            hash.locator(params.id), 
      recoveryId:    params.recoveryId ? hash.locator(params.recoveryId) : null,
      authTokenHash: hash.sha2(params.authToken), 
      mainData:      params.mainData, 
      recoveryData:  params.recoveryData, 
      keychainData:  params.keychainData
    })
    .then(function(params) {
      return db("wallets").insert(params);
    });
}

var loadFixtures = function() {
  return Promise.all([
    makeWallet({ id:'1', recoveryId:'1', authToken:'1', mainData:'foo', recoveryData:'foo', keychainData:'foo' }),
    makeWallet({ id:'3', recoveryId:'3', authToken:'3', mainData:'foo3', recoveryData:'foo3', keychainData:'foo3' }),
    makeWallet({ id:'4', authToken:'4', mainData:'foo4', keychainData:'foo4' })
  ]);
}

helpers.makeString = function(size) {
  var x = "";
  for(var i = 0; i < size; i++) {
    x += "a";
  }
  return x;
}

beforeEach(function(done) {
  clearDb()
    .then(loadFixtures)
    .then(function() { done(); });
});

before(function(done) {
  require("../lib/app")
    .init()
    .then(function(){ 
      done(); 
    });
})

helpers.stexDev = require("stex-dev");
helpers.expect = helpers.stexDev.chai.expect;<commit_msg>Fixes test run by activating stex<commit_after>var Stex    = require("stex");
var hash    = require("../lib/util/hash")
var Promise = Stex.Promise;

var helpers = module.exports;

var clearDb = function() {
  return db.raw("TRUNCATE TABLE wallets");
}

var makeWallet = function(params) {
  return Promise
    .props({ 
      id:            hash.locator(params.id), 
      recoveryId:    params.recoveryId ? hash.locator(params.recoveryId) : null,
      authTokenHash: hash.sha2(params.authToken), 
      mainData:      params.mainData, 
      recoveryData:  params.recoveryData, 
      keychainData:  params.keychainData
    })
    .then(function(params) {
      return db("wallets").insert(params);
    });
}

var loadFixtures = function() {
  return Promise.all([
    makeWallet({ id:'1', recoveryId:'1', authToken:'1', mainData:'foo', recoveryData:'foo', keychainData:'foo' }),
    makeWallet({ id:'3', recoveryId:'3', authToken:'3', mainData:'foo3', recoveryData:'foo3', keychainData:'foo3' }),
    makeWallet({ id:'4', authToken:'4', mainData:'foo4', keychainData:'foo4' })
  ]);
}

helpers.makeString = function(size) {
  var x = "";
  for(var i = 0; i < size; i++) {
    x += "a";
  }
  return x;
}

beforeEach(function(done) {
  clearDb()
    .then(loadFixtures)
    .then(function() { done(); });
});

before(function(done) {
  require("../lib/app")
    .init()
    .then(function(stex){ 
      stex.activate();
      done(); 
    });
})

helpers.stexDev = require("stex-dev");
helpers.expect = helpers.stexDev.chai.expect;
{'fraction_non_alphanumeric': 0.17886717456111295, 'fraction_numerical': 0.009937065253395164, 'mean_word_length': 3.4411764705882355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5353896', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1040, 'n_words': 193}