test: add some unit tests for merkle.cpp #16865

pull soroosh-sdi wants to merge 1 commits into bitcoin:master from soroosh-sdi:13-09-19-merkle-unit-tests changing 1 files +100 −0
  1. soroosh-sdi commented at 5:06 pm on September 13, 2019: contributor

    following situations are covered:

    • empty block
    • one Tx
    • Merkle root of a block with odd Txs should not change with repeating last one
    • Merkle root is computed with combining Merkle root of left subtree and right subtree
    • block witness is Merkle root of a block when setting first Tx to zero.

    Signed-off-by: soroosh-sdi soroosh.sardari@gmail.com

  2. instagibbs commented at 5:20 pm on September 13, 2019: member

    you can remove the boilerplate from “Pull requests without a rationale and clear improvement may be closed immediately.”

    nice submission!

  3. DrahtBot added the label Tests on Sep 13, 2019
  4. soroosh-sdi commented at 5:52 pm on September 13, 2019: contributor
    Thanks bro @instagibbs
  5. soroosh-sdi force-pushed on Sep 14, 2019
  6. in src/test/merkle_tests.cpp:289 in c7b9e4d601 outdated
    284+    for (pos = 0; pos < block.vtx.size(); pos++) {
    285+        CMutableTransaction mtx;
    286+        mtx.nLockTime = pos;
    287+        block.vtx[pos] = MakeTransactionRef(std::move(mtx));
    288+    }
    289+    pos--;
    


    theStack commented at 6:37 am on September 16, 2019:
    This line can be removed, since pos is not used outside the for loop. Also, the declaration and initialization of pos can be combined.

    soroosh-sdi commented at 5:49 pm on September 16, 2019:
    yeah, I forgot to remove this, thanks for warning me.
  7. laanwj commented at 11:12 am on September 16, 2019: member

    Thanks for adding tests, they look good to me.

    A small comment on the commit message; please format commit messages as

    0<title line>
    1<empty line>
    2<more description…>
    

    Currently, due to lack of an empty line after the title, tools will smash all the description text on one line:

    • c7b9e4d601a7df333b84757dde8a1bc9829a6b25 test: add some unit tests for merkle.cpp following situations are covered: - empty block - one Tx - Merkle root of a block with odd Txs should not change with repeating last one - Merkle root is computed with combining Merkle root of left subtree and right subtree - block witness is Merkle root of a block when setting first Tx to zero.

    instead of just

    • c7b9e4d601a7df333b84757dde8a1bc9829a6b25 test: add some unit tests for merkle.cpp
  8. soroosh-sdi force-pushed on Sep 16, 2019
  9. test: add some unit tests for merkle.cpp
    following situations are covered:
    - empty block
    - one Tx
    - Merkle root of a block with odd Txs should not change with repeating
    last one
    - Merkle root is computed with combining Merkle root of left subtree and right subtree
    - block witness is Merkle root of a block when setting first Tx
    to zero.
    
    Signed-off-by: soroosh-sdi <soroosh.sardari@gmail.com>
    8573429d46
  10. soroosh-sdi force-pushed on Sep 16, 2019
  11. soroosh-sdi commented at 3:39 am on September 17, 2019: contributor
    your welcome, commit message edited. @laanwj
  12. laanwj commented at 9:59 am on September 17, 2019: member
    ACK 8573429d46f1e014663695e95109c10dfe4d54c9
  13. MarcoFalke referenced this in commit b3067f4338 on Sep 17, 2019
  14. MarcoFalke merged this on Sep 17, 2019
  15. MarcoFalke closed this on Sep 17, 2019

  16. jasonbcox referenced this in commit 48baf4ea7c on Oct 21, 2020
  17. PastaPastaPasta referenced this in commit 606501e7ca on Jun 27, 2021
  18. PastaPastaPasta referenced this in commit 493e27db19 on Jun 28, 2021
  19. PastaPastaPasta referenced this in commit 1e3db87bcb on Jun 29, 2021
  20. PastaPastaPasta referenced this in commit 9f47971bb5 on Sep 11, 2021
  21. PastaPastaPasta referenced this in commit 83f2f14c21 on Sep 11, 2021
  22. PastaPastaPasta referenced this in commit 9462e30b84 on Sep 12, 2021
  23. PastaPastaPasta referenced this in commit 9c94a2b8c4 on Sep 12, 2021
  24. kittywhiskers referenced this in commit c69d011e2e on Nov 6, 2021
  25. kittywhiskers referenced this in commit 6a775ab0c2 on Dec 5, 2021
  26. kittywhiskers referenced this in commit e0b8f0503b on Dec 5, 2021
  27. kittywhiskers referenced this in commit b0ef742681 on Dec 12, 2021
  28. kittywhiskers referenced this in commit 45e09d4bb0 on Dec 12, 2021
  29. DrahtBot locked this on Dec 16, 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: 2025-12-12 12:13 UTC

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