Page MenuHomePhabricator

[test] CScriptNum Decode Check as Unit Tests

Authored by PiRK on Feb 25 2021, 09:48.


Group Reviewers
Restricted Project
rABC2a3ba49ebbbf: [test] CScriptNum Decode Check as Unit Tests

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 testing fn create_coinbase() with CScriptNum

Backport note:

The functional tests are usually executed individually via a subprocess. This means the get_srcdir() function in 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 itself which is located in the build directory.
So 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 before calling the unittest unittest.TestLoader().loadTestsFromName machinery which causes to be imported.

This is a backport of core#19082

Test Plan

ninja check-functional

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable