<commit_before>import CodeUtils from "../";
import assert from "assert";
import { describe, it } from "mocha";

describe("CodeUtils.parseCode", () => {
  // example contract hex code
  const contractHexCode =
    "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371dc61cb14610051578063ca4bc9eb146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610176565b005b3480156100c657600080fd5b506100fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013b578082015181840152602081019050610120565b50505050905090810190601f1680156101685780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090805190602001906101c892919061027c565b5050565b60006020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102745780601f1061024957610100808354040283529160200191610274565b820191906000526020600020905b81548152906001019060200180831161025757829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102bd57805160ff19168380011785556102eb565b828001600101855582156102eb579182015b828111156102ea5782518255916020019190600101906102cf565b5b5090506102f891906102fc565b5090565b61031e91905b8082111561031a576000816000905550600101610302565b5090565b905600a165627a7a723058201e83a8ab1e70123d8d8f6d7bf1e3edb7be768977f2faaa0d7fc0463ef14e98c70029";

  it("returns an array of instructions", () => {
    const parsedCode = CodeUtils.parseCode(contractHexCode);
    assert(parsedCode);
    assert(Array.isArray(parsedCode));
  });

  it("returns an empty array when passed an empty string array", () => {
    const parsedCode = CodeUtils.parseCode("[]");
    assert(parsedCode);
    assert(Array.isArray(parsedCode));
  });
});<commit_msg>Add test and fix broken test<commit_after>import CodeUtils from "../";
import assert from "assert";
import { describe, it } from "mocha";

describe("CodeUtils.parseCode", () => {
  // example contract hex code
  const contractHexCode =
    "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806371dc61cb14610051578063ca4bc9eb146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610176565b005b3480156100c657600080fd5b506100fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013b578082015181840152602081019050610120565b50505050905090810190601f1680156101685780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090805190602001906101c892919061027c565b5050565b60006020528060005260406000206000915090508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102745780601f1061024957610100808354040283529160200191610274565b820191906000526020600020905b81548152906001019060200180831161025757829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102bd57805160ff19168380011785556102eb565b828001600101855582156102eb579182015b828111156102ea5782518255916020019190600101906102cf565b5b5090506102f891906102fc565b5090565b61031e91905b8082111561031a576000816000905550600101610302565b5090565b905600a165627a7a723058201e83a8ab1e70123d8d8f6d7bf1e3edb7be768977f2faaa0d7fc0463ef14e98c70029";

  it("returns an array of instructions", () => {
    const parsedCode = CodeUtils.parseCode(contractHexCode);
    assert(parsedCode);
    assert(Array.isArray(parsedCode));
  });

  it("returns an empty array when passed an empty string array", () => {
    const parsedCode = CodeUtils.parseCode("[]");
    assert(parsedCode);
    assert(Array.isArray(parsedCode));
    assert(parsedCode.length === 0);
  });

  it("doesn't strip invalid metadata", () => {
    const parsedCode = CodeUtils.parseCode(
      "0x600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600050600060000100"
    );
    assert(parsedCode);
    assert(parsedCode.length === 172);
  });
});
{'fraction_non_alphanumeric': 0.0417524808088373, 'fraction_numerical': 0.6401422954502902, 'mean_word_length': 17.2320819112628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 10, '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': '2350622', 'n_tokens_mistral': 4083, 'n_tokens_neox': 1975, 'n_words': 108}