HomePhabricator

[test] CScriptNum Decode Check as Unit Tests

Description

[test] CScriptNum Decode Check as Unit Tests

Summary:

Migrates the CScriptNum decode tests into a unit test, and moved some
changes made in core#14816. Made possible by the integration of
test_framework unit testing in 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 core#19082

Test Plan: ninja check-functional

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9276

Details

Provenance
Gillian Chu <gillianchu@Gillians-MacBook-Pro.local>Authored on May 27 2020, 17:05
PiRKCommitted on Mar 1 2021, 14:42
PiRKPushed on Mar 1 2021, 14:42
Reviewer
Restricted Project
Differential Revision
D9276: [test] CScriptNum Decode Check as Unit Tests
Parents
rABCea64418dcb25: doc: Add documentation for 'checklevel' argument in 'verifychain' RPC call
Branches
Unknown
Tags
Unknown