This will be used in D16569 to verify the results returned by chronik in the functional test.
Details
- Reviewers
Fabien - Group Reviewers
Restricted Project - Commits
- rABCd13de02951a6: [test framework] add a python implementation for merkle trees
ninja check-functional
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 30276 Build 60079: Build Diff build-clang · build-without-wallet · build-debug · build-clang-tidy · build-diff Build 60078: arc lint + arc unit
Event Timeline
test/functional/test_framework/merkle.py | ||
---|---|---|
49 ↗ | (On Diff #49618) | This can only happen once, no need to check it in the loop |
53 ↗ | (On Diff #49618) | I don't understand the XOR here, can you explain ? |
58 ↗ | (On Diff #49618) | You may also want to check len(hashes) > 0 at the beginning of the function, and special case the returned value |
test/functional/test_framework/merkle.py | ||
---|---|---|
49 ↗ | (On Diff #49618) | Actually it needs to be done in each iteration of the loop. For instance you start with 6 hashes you will not need to duplicate a hash in the first step, but in the second step you will be left with 3 hashes and you will need to duplicate the last one to make it 4. |
53 ↗ | (On Diff #49618) | The XOR tells us which intermediate hash in a given level we want to remember so we can verify that a specific block hash is in a particular merkle tree. For instance with the merkle root for the first 6 hashes of the chain: root = h01234545 h0123 h4545 h01 h23 h45 h45 bh0 bh1 bh2 bh3 bh4 bh5 If you want to verify that bh2 is part of the chain knowing root, you need branch = [bh3, h01, h4545] ìndex is 0 based, so If you have a list of 4 hashes index can not be more than 3. |
test/functional/test_framework/merkle.py | ||
---|---|---|
53 ↗ | (On Diff #49618) | So i think my assertion assert index <= len(hashes) should probably be assert index < len(hashes) |
fix assertion for index vs len(hashes), and also assert that len(hashes) is strictly larger than 0
test/functional/test_framework/merkle.py | ||
---|---|---|
58 ↗ | (On Diff #49618) | This still holds |
test/functional/test_framework/merkle.py | ||
---|---|---|
58 ↗ | (On Diff #49618) | We know have assert 0 < len(hashes) at the begining of the function. I can maybe put a more explicit error, but returning something in this case seems pointless. |
test/functional/test_framework/merkle.py | ||
---|---|---|
58 ↗ | (On Diff #49618) | Oh I see, I was confused by the notation |