Example #1
0
NameIterationTester::EntryList
NameIterationTester::getNamesFromView (const CCoinsView& view,
                                       const valtype& start)
{
  std::auto_ptr<CNameIterator> iter(view.IterateNames ());
  iter->seek (start);

  return getNamesFromIterator (*iter);
}
Example #2
0
void
NameIterationTester::verify (const CCoinsView& view) const
{
  /* Try out everything with all names as "start".  This thoroughly checks
     that also the start implementation is correct.  It also checks using
     a single iterator and seeking vs using a fresh iterator.  */

  valtype start;
  EntryList remaining(data.begin (), data.end ());

  /* Seek the iterator to the end first for "maximum confusion".  This ensures
     that seeking to valtype() works.  */
  std::auto_ptr<CNameIterator> iter(view.IterateNames ());
  const valtype end = ValtypeFromString ("zzzzzzzzzzzzzzzz");
  {
    valtype name;
    CNameData data;

    iter->seek (end);
    BOOST_CHECK (!iter->next (name, data));
  }

  while (true)
    {
      EntryList got = getNamesFromView (view, start);
      BOOST_CHECK (got == remaining);

      iter->seek (start);
      got = getNamesFromIterator (*iter);
      BOOST_CHECK (got == remaining);

      if (remaining.empty ())
        break;

      if (start == remaining.front ().first)
        remaining.pop_front ();

      if (remaining.empty ())
        start = end;
      else
        start = remaining.front ().first;
    }
}