test: Add more thorough test for dbwrapper iterators #7956

pull laanwj wants to merge 2 commits into bitcoin:master from laanwj:2016_04_dbwrapper_iterator_tess changing 2 files +36 −1
  1. laanwj commented at 9:13 am on April 27, 2016: member

    I made a silly mistake in an experimental database wrapper where keys were sorted by char instead of uint8_t. As x86 char is signed the sorting (and thus seeking) for the block index database was messed up, resulting in a segfault due to missing records. This should be caught by the tests.

    Add a test to catch:

    • Wrong sorting
    • Seeking errors
    • Iteration result not complete
    • Wrong keys/values from iterator

    Also add an assertion to CBlockIndex::GetAncestor, as this it the place it will segfault when block index records are missing. An assertion error is easier to diagnose than a pointer crash (although what we really need is a start-up check whether the database is complete otherwise suggest a reindex).

  2. chain: Add assertion in case of missing records in index db 84c13e759d
  3. test: Add more thorough test for dbwrapper iterators
    I made a silly mistake in a database wrapper where keys
    were sorted by char instead of uint8_t. As x86 char is signed
    the sorting for the block index database was messed up, resulting
    in a segfault due to missing records.
    
    Add a test to catch:
    - Wrong sorting
    - Seeking errors
    - Iteration result not complete
    6030625631
  4. laanwj added the label Tests on Apr 27, 2016
  5. laanwj added the label UTXO Db and Indexes on Apr 27, 2016
  6. jonasschnelli commented at 12:08 pm on April 27, 2016: contributor
    utACK 6030625631c62b0ffab2ac545c8351fa59dca483
  7. laanwj commented at 10:18 am on April 28, 2016: member
    I think this needs another check: that shorter keys get sorted before longer keys if they’re otherwise the same. I don’t think that we use variable-length keys anywhere, at least not within the same key prefix, but it’s good to have the sorting be well-defined as lexicographic.
  8. laanwj commented at 10:48 am on May 3, 2016: member
    Closing in favor of #7992
  9. laanwj closed this on May 3, 2016

  10. sipa referenced this in commit ec45cc5e27 on Jun 2, 2016
  11. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me