Unify claimtrie tests, add some additional root hash checks #181
No reviewers
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#181
Loading…
Reference in a new issue
No description provided.
Delete branch "unify_claimtrie_tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As part of the review, look for the comment "tx1MerkleHash doesn't match right here" and tell me if that's expected.
If this isn't ready yet, consider adding WIP (for work in progress to the PR name).
Will review more later
@ -656,2 +664,3 @@
BOOST_CHECK(is_best_claim("test",u3));
fixture.DecrementBlocks(11);
BOOST_CHECK_EQUAL(2U, pclaimTrie->getClaimsForName("test").claims.size());
fixture.DecrementBlocks(11);
The previous test names were far more descriptive when tracking down logged errors. It described module and the test name, not a name with "_test" appended (which is non-informative, given that all unit tests are tests).
Also, just a general question -- why are these being merged? I liked having the older tests separate from the more recent ones, which can help find regressions (have actually found several while I was working on the normalization).
@ -656,2 +664,3 @@
BOOST_CHECK(is_best_claim("test",u3));
fixture.DecrementBlocks(11);
BOOST_CHECK_EQUAL(2U, pclaimTrie->getClaimsForName("test").claims.size());
fixture.DecrementBlocks(11);
The filename is actually part of the displayed name for both error and when running it manually; it ends up being "claimtriebranching_tests/claimtriebranching_support", etc. Hence, I didn't see the purpose in keeping the namespace duplicated in the test name. I'm not crazy about ending them with "_test", either. It just looked like that's what some other files did. I still think most of the names are not helpful. All of the tests cover more ground than their name implies, and many of the test names are too generic.
As for the "why" question, @kaykurokawa can say why he filed #83 . There is 200 lines less code than there was before the test merge, and the old tests are still covering everything that they did before. It's just not so obvious now that they're older.
I think I finally got the right format command figured out. I'll push up that commit to make sure it builds on Travis. I'm happy to squash this before we merge, but I think the different commits allow you to more easily see what was added to test hashes and tree counts.
Everyone has different opinions here, but my take is that pull requests with many commits are just distracting since either the pull request addresses the issue or not. Most times when you see a stack of commits, they are exactly things like "ran formatting tool", "updated test", "something else useless", etc. In reality, reviewers look at the change-set as a whole because the PR is more or less all or nothing. Cherry-picking individual commits from a single PR is very rare -- I'd dare say it never happens. Instead you see even more garbage commits like "updated test", " fixed the issue added by test", "reverted last change", "really updated test".
Developers tend to overvalue the sequence of how code arrived at a particular place -- for example, a common argument I hear for not squashing is that so that a particular developer can remember the process of making the changes, or some other sentimental/historical reason. The problem is that anyone can do that in a local tree, but it's meaningless (and distracting) to other developers, the ones reviewing and/or maintaining it -- who are not interested in that sequence, and it actually makes history tracking somewhat more difficult because instead of a concrete place where PR X was merged (which can be reviewed/edited/undone), you have to potentially suffer through reviewing 40+ commits to find the actual spot where something happened/broke/changed (including all the 10+ other commits in there where it was twiddled back and forth for whatever reason during the 'process').
This is a bit of rant, not particularly just about your comment @BrannonKing. I find clean source histories very important, particularly when we are looking to be tracking an upstream. It's the entire reason that git is more powerful than other scms (the ability to hack/clean the timeline). I'm just advocating for professional standards on the main public repo. Of course, anyone can do whatever they'd like on their personal repos.
@kaykurokawa and I largely agreed that squashing the commits was the least noisy (last we talked about it, although it's been a while). If you find that this is not the right thing to do in some cases, just make the case. But keep the above in mind. There's nothing wrong with formatting PRs, but they would ideally just be formatting -- not formatting and overhaul subsystem X at the same time.
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
This mismatch on the end is what was causing the Travis-CI test failure. Strange thing: it doesn't fail with the GCC 7 builds, with or without optimizations. Only the GCC 4 builds fail.
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
Interesting. If you're able to track down why that is, it may save us some headaches in the future. Once we are inline with upstream, gcc 5/6/7/8 becomes a viable option, perhaps even a minimum supported version.
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
This looks like a bug?
std::vector<unsigned char>(sValue1.begin(), sValue2.end())
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
Also, does the construction form make any difference?
Changing something like:
to
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
On second read ... are you just saying that the mismatch is what the actual problem is and later compilers don't notice it? We can play with the warning levels if so later.
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
Neither compiler caught the error. It was a runtime failure. When, compiled with GCC7, though, the unit test passes with no runtime failure notwithstanding the wrong end sentinel. I tried to do your
data() + size()
suggestion but that won't compile; it definitely wants an end sentinel, not a real pointer.@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
Ah right, it would require a temporary, (I hacked it since we're not using c++11). The preferred syntax (c++11) would be:
The test without is something like:
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
BTW, if the test passes with that bug, there's another bug at the surface.
@ -1067,0 +1463,4 @@
fixture.CommitTx(tx1);
fixture.IncrementBlocks(1, true);
BOOST_CHECK(pclaimTrie->getInfoForName(sName1, val));
I didn't notice the
data()
on the first parameter previously. This does compile and also does not throw a runtime error in GCC7:... std::vector<unsigned char>(sValue1.data(), sValue2.data() + sValue2.size()) ...
. It probably works because sValue1 and sValue2 are in order on the stack; you end up with sValue1 prepended to sValue2 with some junk in the middle, but we never verify the value.I believe that I now understand my question where the claimtrie merkle root hash didn't match: the height (er, block number) where the transaction is activated (known as node->nHeightOfLastTakeover) is also included in the hash input. The upper one is activated at height 141; the lower at height 153.
Pull request closed