Nits in mempool_tests/MempoolIndexingTest #21642

issue kiminuo opened this issue on April 9, 2021
  1. kiminuo commented at 11:52 AM on April 9, 2021: contributor

    Hi,

    I have been reading mempool_tests.cpp file and maybe there are two things that can be improved in MempoolIndexingTest:

    1) Typo

    Line https://github.com/bitcoin/bitcoin/blob/4ad83a9597e4f5340742d080e26437c5d8d203ba/src/test/mempool_tests.cpp#L223 should be:

    // Now tx8 should be sorted low, but tx6/tx7 both high
    

    2) Extra lines

    It looks to me that these two lines are not needed:

    https://github.com/bitcoin/bitcoin/blob/4ad83a9597e4f5340742d080e26437c5d8d203ba/src/test/mempool_tests.cpp#L291-L292

    The PR #12127 (here) is the PR to understand the current status quo.

    PS: A digram for the MempoolIndexingTest would make it easier to follow.

    3) Asserted order

    I would add a comment like this

    // Verify order: tx8 (0), tx3 (0), tx5 (10k), tx1 (10k), tx4 (15k), tx2 (20k), tx6 (0+2000k) and tx7 (2000k)
    

    for https://github.com/bitcoin/bitcoin/blob/4ad83a9597e4f5340742d080e26437c5d8d203ba/src/test/mempool_tests.cpp#L225 line as at that point, it's probably not that easy to know where we are unless one uses pen and paper.

    4) GetTransactionAncestry in txmempool.{h,cpp}

    GetTransactionAncestry is described here: https://github.com/bitcoin/bitcoin/blob/1e3db6807d1809182c799b5f7a78843f03fbe413/src/txmempool.h#L707-L710 but the comment:

    • Calculate the ancestor and descendant count for the given transaction.
    • The counts include the transaction itself.

    may be improved with better wording because descendants does not represent the number of descendants of the txid transaction but rather a maximum number of descendants of the txid transaction or any of the txid parents (parents are searched recursively) if I read the code correctly. In any case, it may be helpful to rename descendants to maxDescendants not to confuse a reader.

  2. kiminuo added the label Bug on Apr 9, 2021
  3. glozow removed the label Bug on Aug 4, 2022
  4. glozow added the label Docs on Aug 4, 2022
  5. glozow commented at 9:23 AM on August 4, 2022: member

    Thanks for your suggestions, feel free to open a PR to request changes.

  6. bitcoin deleted a comment on Aug 4, 2022
  7. glozow closed this on Aug 9, 2022

  8. bitcoin locked this on Aug 9, 2023

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: 2026-04-22 18:14 UTC

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