Page MenuHomePhabricator

[test] CScriptNum Decode Check as Unit Tests
ClosedPublic

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

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC2a3ba49ebbbf: [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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable