<commit_before>import debugModule from "debug";
const debug = debugModule("test:data:decode");

import Ganache from "ganache-cli";
import Web3 from "web3";
import { assert } from "chai";
import changeCase from "change-case";

import { prepareContracts } from "test/helpers";

import Debugger from "lib/debugger";

import * as TruffleDecodeUtils from "truffle-decode-utils";

import data from "lib/data/selectors";

export function *generateUints() {
  let x = 0;
  while (true) {
    yield x;
    x++;
  }
}

function contractName(testName) {
  return testName.replace(/ /g, "");
}

function fileName(testName) {
  return `${contractName(testName)}.sol`;
}


function generateTests(fixtures) {
  for (let { name, value: expected } of fixtures) {
    it(`correctly decodes ${name}`,
      () => { assert.deepEqual(this.decode(name), expected); }
    );
  }
}

function lastStatementLine(source) {
  const lines = source.split("\n");
  for (let i = lines.length - 1; i >= 0; i--) {
    let line = lines[i];
    if (line.indexOf(";") != -1) {
      return i;
    }
  }
}


async function prepareDebugger(testName, sources) {
  const provider = Ganache.provider({seed: "debugger", gasLimit: 7000000});
  const web3 = new Web3(provider);

  let { abstractions, artifacts: contracts, files } =
    await prepareContracts(provider, sources);

  let instance = await abstractions[contractName(testName)].deployed();<commit_msg>make sure to wait for the decode function to finish<commit_after>import debugModule from "debug";
const debug = debugModule("test:data:decode");

import Ganache from "ganache-cli";
import Web3 from "web3";
import { assert } from "chai";
import changeCase from "change-case";

import { prepareContracts } from "test/helpers";

import Debugger from "lib/debugger";

import * as TruffleDecodeUtils from "truffle-decode-utils";

import data from "lib/data/selectors";

export function *generateUints() {
  let x = 0;
  while (true) {
    yield x;
    x++;
  }
}

function contractName(testName) {
  return testName.replace(/ /g, "");
}

function fileName(testName) {
  return `${contractName(testName)}.sol`;
}


function generateTests(fixtures) {
  for (let { name, value: expected } of fixtures) {
    it(`correctly decodes ${name}`,
      async () => { assert.deepEqual(await this.decode(name), expected); }
    );
  }
}

function lastStatementLine(source) {
  const lines = source.split("\n");
  for (let i = lines.length - 1; i >= 0; i--) {
    let line = lines[i];
    if (line.indexOf(";") != -1) {
      return i;
    }
  }
}


async function prepareDebugger(testName, sources) {
  const provider = Ganache.provider({seed: "debugger", gasLimit: 7000000});
  const web3 = new Web3(provider);

  let { abstractions, artifacts: contracts, files } =
    await prepareContracts(provider, sources);

  let instance = await abstractions[contractName(testName)].deployed();
{'fraction_non_alphanumeric': 0.14473684210526316, 'fraction_numerical': 0.01038781163434903, 'mean_word_length': 4.104240282685512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1361572', 'n_tokens_mistral': 946, 'n_tokens_neox': 926, 'n_words': 252}