-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Moved the CScriptNum asserts into the unit test in script.py #19082
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
Conversation
Concept ACK It would be good to motivate the change. Maybe something like this? The scriptnum test (#14816) is a roundtrip test of the test framwork. Thus, it would be better suited as a unit test. This is now possible with the introduction of the unit test module for the functional tests. See #18576 |
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.
Concept ACK, I suggest trying to undo some of your changes in mining_basic.py
so that you aren't touching any extra lines. You could squash your commits to try to make it easier to see overall changes (you'll need to do this anyway).
There's also some description/naming conventions you could take a look at in the contributing doc as well. For example, adding [test]
to the commit message and PR title.
Concept ACK: more testing is better! Welcome as a contributor @gillichu :) |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
Almost ACK 9d5dd87
Thanks for you contribution. Looks good to me. A small nit: please change the git commit message to a short title (up to say, 70 characters), then an empty line, then the rest of the description. This because tools (such as
|
c368d24
to
401487d
Compare
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.
Welcome to the project @gillichu, and thanks for your contribution ! I have a couple of small suggestions inline.
test/functional/mining_basic.py
Outdated
# round-trip the encoded bip34 block height commitment | ||
assert_equal(CScriptNum.decode(coinbase_tx.vin[0].scriptSig), next_height) |
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 seems to be a test of the create_coinbase()
function in blocktools.py. It might be worth moving it to a unit test there.
A couple more suggestions for the commit log and PR description:
See https://chris.beams.io/posts/git-commit/ for more tips on writing great commit logs. |
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.
Almost there
@@ -91,12 +91,6 @@ def assert_submitblock(block, result_str_1, result_str_2=None): | |||
coinbase_tx.rehash() | |||
|
|||
# round-trip the encoded bip34 block height commitment |
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.
delete this comment?
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 hasn't been deleted.
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.
Sorry about that :( I'll watch my changes more carefully next time, and look for a chance to take this out in the future.
91c0820
to
6092784
Compare
Migrates the CScriptNum decode tests into a unit test, and moved some changes made in bitcoin#14816. Made possible by the integration of test_framework unit testing in bitcoin#18576. Further extends the original test with larger ints, similar to the scriptnum_tests.cpp file. Adds test to blocktools.py testing fn create_coinbase() with CScriptNum decode.
Thanks @gillichu. I think the PR title, commit summary and commit details could be made a bit clearer:
|
ACK 7daffc6 |
… test in script.py 7daffc6 [test] CScriptNum Decode Check as Unit Tests (Gillian Chu) Pull request description: The CScriptNum test (bitcoin#14816) is a roundtrip test of the test framework. Thus, it would be better suited as a unit test. This is now possible with the introduction of the unit test module for the functional tests. See bitcoin#18576. This PR: 1. Refactors the CScriptNum tests into 2 unit tests, one in script.py and one in blocktools.py. 2. Extends the script.py CScriptNum test to trial larger numbers. ACKs for top commit: laanwj: ACK 7daffc6 Tree-SHA512: 17a04a4bfff1b1817bfc167824c679455d9e06e6e0164c00a7e44f8aa5041c5f5080adcc1452fd80ba1a6d8409f976c982bc481d686c434edf97a5893a32a436
fa98e10 test: Remove leftover comment in mining_basic (MarcoFalke) faedb50 test: pep-8 mining_basic (MarcoFalke) Pull request description: Remove an accidental leftover comment from #19082, which no longer applies and thus might be confusing ACKs for top commit: adamjonas: code review ACK fa98e10 Tree-SHA512: c7f7f8f579b3c6e92f45769be0a7af1a421438a3f5524db5278b2269511a9e0e08f44e3836afb26727644035897ee51ff8296d13ce23030549e7403f57b40e40
fa98e10 test: Remove leftover comment in mining_basic (MarcoFalke) faedb50 test: pep-8 mining_basic (MarcoFalke) Pull request description: Remove an accidental leftover comment from bitcoin#19082, which no longer applies and thus might be confusing ACKs for top commit: adamjonas: code review ACK fa98e10 Tree-SHA512: c7f7f8f579b3c6e92f45769be0a7af1a421438a3f5524db5278b2269511a9e0e08f44e3836afb26727644035897ee51ff8296d13ce23030549e7403f57b40e40
Summary: > Migrates the CScriptNum decode tests into a unit test, and moved some > changes made in [[bitcoin/bitcoin#14816 | core#14816]]. Made possible by the integration of > test_framework unit testing in [[bitcoin/bitcoin#18576 | core#18576]]. Further extends the original > test with larger ints, similar to the scriptnum_tests.cpp file. Adds > test to blocktools.py testing fn create_coinbase() with CScriptNum > decode. Backport note: The functional tests are usually executed individually via a `subprocess`. This means the `get_srcdir()` function in cdefs.py is able to find the proper source directory, because the parent directory of the python process is the project root that contains `src/`. But when we run the new test_framework unit test, the process currently running is `test_runner.py` itself which is located in the build directory. So cdefs.py finds the wrong `src/` directory, the one located in the build directory, which does not contain `consensus.h`. I fixed this by setting the environment variable `SRCDIR` in `test_runner.py` before calling the unittest `unittest.TestLoader().loadTestsFromName` machinery which causes `cdefs.py` to be imported. This is a backport of [[bitcoin/bitcoin#19082 | core#19082]] Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9276
The CScriptNum test (#14816) is a roundtrip test of the test framework. Thus, it would be better suited as a unit test. This is now possible with the introduction of the unit test module for the functional tests. See #18576.
This PR: