New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch testing framework from MAIN to new UNITTEST network #4845
Conversation
UNITTEST inherites from MAIN but allows synamically changing its parameters using the ModifiableParams() interface
@@ -2330,6 +2330,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex | |||
nHeight = pindexPrev->nHeight+1; | |||
|
|||
// Check proof of work | |||
if (!Params().SkipProofOfWorkCheck()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird, is it missing an indentation below or some brackets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just fold it into the expression with &&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing indentation below.
But this is on purpose: I want critical consensus code not even look as modified so everyone can evaluate security at eyesight.
Looking good! Most of my comments are minor style points. 👍 |
Also new test case testing the PoW skip in UNITTEST.
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/p4845_eda4aa19d3cafc1644f5c28c687741a6c255b9a6/ for binaries and test log. This could happen for one of several reasons:
If you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ |
Great, thanks! I didn't try running the tests myself but the code looks good to me. |
I would like to know if there is a plan to add this patch to master or a reason not to. I have another patch waiting with more test cases that requires this patch to work! Thanks. |
I haven't reviewed all code, but the changes to the existing core code and tests do seem safe to me. |
Had to be rebased for the clang code formatting change, as well as some other (base)chainparams changes. |
I'm not too happy about a virtual being introduced into CChainParams. Can we avoid this?
Edit: yes we can, see 4705902 |
ACK - will merge after you've sanity-checked my rebased version. |
4705902 Avoid introducing a virtual into CChainParams (Wladimir J. van der Laan) 5e2e7fc Suggested corrections on comments, variable names. Also new test case testing the PoW skip in UNITTEST. (SergioDemianLerner) a25fd6b Switch testing framework from MAIN to new UNITTEST network (SergioDemianLerner)
Oops - this was marked by Travis as ok, but is failing the windows tests now after I tried to merge. See
Lots of:
See #5030. |
It breaks the new mingw tests! See - https://travis-ci.org/bitcoin/bitcoin/jobs/36845581 - https://travis-ci.org/bitcoin/bitcoin/jobs/36845582 This reverts commit 4705902, 5e2e7fc, a25fd6b.
Closing this. The modifiable parameters part has been merged (see #5030). The blocksv2 test case that relies on being executed in a specific order w/ miner_tests has not, as that's not acceptable (as it makes the test framework non-deterministic, and makes it impossible to run testcases separately). Please find a different solution for that. |
This is our third attempt to improve the testing framework taking into account all previous comments and suggestions. The two previous attempts are: pull requests #4688 and #4732.
Summary: For several reasons the current test framework does not allow to easily incorporate new unit tests that append specially crafted blocks to the blockchain using ProcessBlock().
After we proposed a solution in #4688 @gmaxwell and @laanwj suggested not implementing the changes because many files not directly related to the testing framework were modified by the patch.
In the pull request #4732 we implement @gmaxwell suggestion that the test framework should run under the RegTest network parameters and not under the main network parameters. It was discovered that 10 unit cases are designed for the MAIN net, RegTest inherits from TestNet, which has many differences, so switching is not simple nor desired. @mikehearn and @laanwj proposed using a special new network called UNITTEST to be as similar to the real net as possible. We implemented this final suggestion.
In this pull request we implement UNITTEST. We reintroduced the criticized possibility to disable PoW check, but we did it under Params().SkipProofOfWorkCheck(). This method is a const virtual function that returns false for MAIN net, so there is no possibility that it is switched to true, under normal circumstances. This change does not extend the attack surface in any way.
The child network UNITTEST overrides SkipProofOfWorkCheck() to provide the skipping functionality.
To allow test cases to modify network parameters, we've added the ModifiableParams() global variable and associated abstract interface, with setters. These setters are only available if the current network is UNITTEST. Again, there is no way to modify the network parameters if the current network is not UNITTEST.
As in the previous pull requests, we've:
a. fixed the bug in miner_tests.cpp which leaves in the memory pool invalid transactions (mempool.clear() missing).
b. Added 7 unit tests:
ToCheckBlockUpgradeMajority (untested before)
EnforceBlockUpgradeMajority (untested before)
RejectBlockOutdatedMajority (untested before)
"bad-cb-height"
"bad-version"
"time-too-old"
"bad-txns-nonfinal"
Sergio Demian Lerner & Timo Hanke