<commit_before>const Trie = require('../src/index.js')
const async = require('async')
const tape = require('tape')
const testing = require('ethereumjs-testing')

tape('offical tests', async (t) => {
  const jsonTests = testing.getSingleFile('TrieTests/trietest.json')
  const testNames = Object.keys(jsonTests)
  let trie = new Trie()
  async.eachSeries(testNames, function (i, done) {
    let inputs = jsonTests[i].in
    let expect = jsonTests[i].root

    async.eachSeries(inputs, function (input, done) {
      for (i = 0; i < 2; i++) {
        if (input[i] && input[i].slice(0, 2) === '0x') {
          input[i] = new Buffer(input[i].slice(2), 'hex')
        }
      }

      trie.put(new Buffer(input[0]), input[1], function () {
        done()
      })
    }, function () {
      t.equal('0x' + trie.root.toString('hex'), expect)
      trie = new Trie()
      done()
    })
  }, t.end)
})

tape('offical tests any order', function (t) {
  const jsonTests = testing.getSingleFile('TrieTests/trieanyorder.json')
  var testNames = Object.keys(jsonTests)<commit_msg>Fix linting error<commit_after>const Trie = require('../src/index.js')
const async = require('async')
const tape = require('tape')
const testing = require('ethereumjs-testing')

tape('offical tests', function (t) {
  const jsonTests = testing.getSingleFile('TrieTests/trietest.json')
  const testNames = Object.keys(jsonTests)
  let trie = new Trie()
  async.eachSeries(testNames, function (i, done) {
    let inputs = jsonTests[i].in
    let expect = jsonTests[i].root

    async.eachSeries(inputs, function (input, done) {
      for (i = 0; i < 2; i++) {
        if (input[i] && input[i].slice(0, 2) === '0x') {
          input[i] = new Buffer(input[i].slice(2), 'hex')
        }
      }

      trie.put(new Buffer(input[0]), input[1], function () {
        done()
      })
    }, function () {
      t.equal('0x' + trie.root.toString('hex'), expect)
      trie = new Trie()
      done()
    })
  }, t.end)
})

tape('offical tests any order', function (t) {
  const jsonTests = testing.getSingleFile('TrieTests/trieanyorder.json')
  var testNames = Object.keys(jsonTests)
{'fraction_non_alphanumeric': 0.17086834733893558, 'fraction_numerical': 0.008403361344537815, 'mean_word_length': 3.185546875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '2045585', 'n_tokens_mistral': 744, 'n_tokens_neox': 732, 'n_words': 163}