<commit_before>/* global beforeEach describe it */

var assert = require('assert')
var bitcoinjs = require('bitcoinjs-lib')

var Account = require('../src/account')
var Chain = require('../src/chain')
var fixtures = require('./fixtures/account')

describe('Account', function () {
  var account, parents, f

  beforeEach(function () {
    f = fixtures.valid[0]
    parents = [
      bitcoinjs.HDNode.fromBase58(f.external),
      bitcoinjs.HDNode.fromBase58(f.internal)
    ]
    var chains = parents.map(function (node) {
      return new Chain(node.neutered())
    })

    account = new Account(chains)
  })

  describe('containsAddress', function () {
    beforeEach(function () {
      for (var i = 1; i < f.addresses.length; ++i) {
        account.nextChainAddress(0)
        account.nextChainAddress(1)
      }
    })

    it('returns true for known addresses', function () {
      f.addresses.forEach(function (address) {
        assert(account.containsAddress(address))
      })
    })

    it('returns false for unknown addresses', function () {
      assert(!account.containsAddress('mpFZW4A9QtRuSpuh9SmeW7RSzFE3TgB8Ko'))
    })
  })

  describe('getAllAddresses', function () {
    beforeEach(function () {
      for (var i = 1; i < f.addresses.length; ++i) {
        account.nextChainAddress(0)
        account.nextChainAddress(1)
      }
    })

    it('returns all known addresses from both chains', function () {
      var allAddresses = f.addresses.concat(f.changeAddresses)

      assert.deepEqual(account.getAllAddresses(), allAddresses)
    })
  })

  describe('getChainAddress', function () {
    it('returns the latest address on chain i', function () {
      f.addresses.forEach(function (address) {
        assert.equal(account.getChainAddress(0), address)

        account.nextChainAddress(0)
      })
<commit_msg>tests: add failing tests for account after construction<commit_after>/* global beforeEach describe it */

var assert = require('assert')
var bitcoinjs = require('bitcoinjs-lib')

var Account = require('../src/account')
var Chain = require('../src/chain')
var fixtures = require('./fixtures/account')

describe('Account', function () {
  var account, parents, f

  beforeEach(function () {
    f = fixtures.valid[0]
    parents = [
      bitcoinjs.HDNode.fromBase58(f.external),
      bitcoinjs.HDNode.fromBase58(f.internal)
    ]
    var chains = parents.map(function (node) {
      return new Chain(node.neutered())
    })

    account = new Account(chains)
  })

  describe('containsAddress', function () {
    beforeEach(function () {
      for (var i = 1; i < f.addresses.length; ++i) {
        account.nextChainAddress(0)
        account.nextChainAddress(1)
      }
    })

    it('returns true for known addresses', function () {
      f.addresses.forEach(function (address) {
        assert(account.containsAddress(address))
      })
    })

    it('returns false for unknown addresses', function () {
      assert(!account.containsAddress('mpFZW4A9QtRuSpuh9SmeW7RSzFE3TgB8Ko'))
    })
  })

  describe('getAllAddresses', function () {
    it('returns all known addresses from both chains', function () {
      for (var i = 1; i < f.addresses.length; ++i) {
        account.nextChainAddress(0)
        account.nextChainAddress(1)
      }

      var allAddresses = f.addresses.concat(f.changeAddresses)

      assert.deepEqual(account.getAllAddresses(), allAddresses)
    })

    it('returns 2 addresses after construction', function () {
      assert.equal(account.getAllAddresses().length, 2)
    })
  })

  describe('getChainAddress', function () {
    it('returns the latest address on chain i', function () {
      f.addresses.forEach(function (address) {
        assert.equal(account.getChainAddress(0), address)

        account.nextChainAddress(0)
      })

{'fraction_non_alphanumeric': 0.13546862693620373, 'fraction_numerical': 0.010501443948542924, 'mean_word_length': 3.1278439869989167, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6388320', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1128, 'n_words': 234}