dash/src/test
Wladimir J. van der Laan 452d182739
Merge #14696: qa: Add explicit references to related CVE's in p2p_invalid_block test.
0c62e3aa73839e97e65a3155e06a98d84b700a1e New regression testing for CVE-2018-17144, CVE-2012-2459, and CVE-2010-5137. (lucash-dev)
38bfca6bb2ad68719415e9c54a981441052da072 Added comments referencing multiple CVEs in tests and production code. (lucash-dev)

Pull request description:

  This functional test includes two scenarios that test for regressions of vulnerabilities, but they are only briefly described. There are freely available documents explaining in detail the issues, but without explicit mentions, the developer trying to maintain the code needs an additional step of digging in commit history and PR conversations to figure it out.
  Added comments to explicitly mention  CVE-2018-17144 and CVE-2012-2459, for more complete documentation.
  This improves developer experience by making understanding the tests easier.

ACKs for top commit:
  laanwj:
    ACK 0c62e3aa73839e97e65a3155e06a98d84b700a1e, checked the CVE numbers, thanks for adding documentation

Tree-SHA512: 3ee05351745193b8b959e4a25d50f25a693b2d24b0732ed53cf7d5882df40b5dd0f1877bd5c69cffb921d4a7acf9deb3cc1160b96dc730d9b5984151ad06b7c9
2021-12-15 20:09:58 +05:30
..
data Merge #14696: qa: Add explicit references to related CVE's in p2p_invalid_block test. 2021-12-15 20:09:58 +05:30
fuzz Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
addrman_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
allocator_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
amount_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
arith_uint256_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
base32_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
base58_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
base64_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
bech32_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
bip32_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
bip39_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
block_reward_reallocation_tests.cpp test: replace feature_block_reward_reallocation.py with two corresponding unit tests (#4603) 2021-12-11 23:01:20 +03:00
blockchain_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
blockencodings_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
blockfilter_index_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
blockfilter_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
bloom_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
bls_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
bswap_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
cachemap_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
cachemultimap_tests.cpp fix: resolve numerous compilation warnings under -Wall (#4599) 2021-12-01 22:59:34 +03:00
checkdatasig_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
checkqueue_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
coins_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
compilerbug_tests.cpp Merge #15985: Add test for GCC bug 90348 2021-11-09 14:08:50 -05:00
compress_tests.cpp Merge #17220: tests: Add unit testing for the CompressScript function 2021-11-03 12:24:05 -04:00
crypto_tests.cpp partial Merge #15919: Remove unused OpenSSL includes to make it more clear where OpenSSL is used 2021-11-21 07:13:12 +05:30
cuckoocache_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
dbwrapper_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
denialofservice_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
descriptor_tests.cpp merge bitcoin#16570: Make descriptor tests deterministic 2021-12-05 15:47:46 +05:30
dip0020opcodes_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
dynamic_activation_thresholds_tests.cpp test: replace feature_block_reward_reallocation.py with two corresponding unit tests (#4603) 2021-12-11 23:01:20 +03:00
evo_deterministicmns_tests.cpp Merge pull request #4511 from kittywhiskers/bench 2021-10-25 22:58:54 +03:00
evo_simplifiedmns_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
flatfile_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
fs_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
getarg_tests.cpp merge bitcoin#16097: Add Flags enum to ArgsManager class (#4569) 2021-11-12 19:25:46 -05:00
governance_validators_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
hash_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
key_io_tests.cpp Merge pull request #4511 from kittywhiskers/bench 2021-10-25 22:58:54 +03:00
key_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
lcg.h Consensus: DIP-0020: Dash opcode updates. Remaining dip0020 opcodes (#3893) 2021-01-13 14:45:04 -06:00
limitedmap_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
logging_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
main.cpp bitcoin#15504: Link BasicTestingSetup (shared with unit tests) 2021-08-11 09:48:40 +05:30
Makefile
mempool_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
merkle_tests.cpp merge bitcoin#16865: add some unit tests for merkle.cpp 2021-12-12 18:57:02 +05:30
merkleblock_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
miner_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
multisig_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
net_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
netbase_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
pmt_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
policyestimator_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
pow_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
prevector_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
raii_event_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
random_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
ratecheck_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
README.md merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
reverselock_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
rpc_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
sanity_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
scheduler_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
script_p2pk_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
script_p2pkh_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
script_p2sh_tests.cpp merge bitcoin#15638: Pull wallet code out of libbitcoin_server (#4560) 2021-11-16 10:19:47 -05:00
script_standard_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
script_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
scriptnum10.h Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
scriptnum_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
serialize_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
setup_common.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
setup_common.h Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
sighash_tests.cpp merge bitcoin#15638: Pull wallet code out of libbitcoin_server (#4560) 2021-11-16 10:19:47 -05:00
sigopcount_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
skiplist_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
specialtx_tests.cpp add ehf special tx (#4577) 2021-12-11 23:00:27 +03:00
streams_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
subsidy_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
sync_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
timedata_tests.cpp Merge #16563: test: Add unit test for AddTimeData 2021-11-03 12:24:04 -04:00
torcontrol_tests.cpp Merge pull request #4511 from kittywhiskers/bench 2021-10-25 22:58:54 +03:00
transaction_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
txindex_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
txvalidation_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
txvalidationcache_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
uint256_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
util_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
util_threadnames_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
util.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
util.h partial bitcoin#15779: wallet_balance benchmark 2021-10-25 21:28:37 +05:30
validation_block_tests.cpp Merge #16278: tests: Remove unused includes (#4528) 2021-11-30 00:53:40 -05:00
validation_flush_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
validation_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30
versionbits_tests.cpp merge bitcoin#15788: Unify testing setups for fuzz, bench, and unit tests 2021-10-25 21:28:37 +05:30

Compiling/running unit tests

Unit tests will be automatically compiled if dependencies were met in ./configure and tests weren't explicitly disabled.

After configuring, they can be run with make check.

To run the dashd tests manually, launch src/test/test_dash. To recompile after a test file was modified, run make and then run the test again. If you modify a non-test file, use make -C src/test to recompile only what's needed to run the dashd tests.

To add more dashd tests, add BOOST_AUTO_TEST_CASE functions to the existing .cpp files in the test/ directory or add new .cpp files that implement new BOOST_AUTO_TEST_SUITE sections.

To run the dash-qt tests manually, launch src/qt/test/test_dash-qt

To add more dash-qt tests, add them to the src/qt/test/ directory and the src/qt/test/test_main.cpp file.

Running individual tests

test_dash has some built-in command-line arguments; for example, to run just the getarg_tests verbosely:

test_dash --log_level=all --run_test=getarg_tests

... or to run just the doubledash test:

test_dash --run_test=getarg_tests/doubledash

Run test_dash --help for the full list.

Note on adding test cases

The sources in this directory are unit test cases. Boost includes a unit testing framework, and since Dash Core already uses boost, it makes sense to simply use this framework rather than require developers to configure some other framework (we want as few impediments to creating unit tests as possible).

The build system is setup to compile an executable called test_dash that runs all of the unit tests. The main source file is called setup_common.cpp. To add a new unit test file to our test suite you need to add the file to src/Makefile.test.include. The pattern is to create one test file for each class or source file for which you want to create unit tests. The file naming convention is <source_filename>_tests.cpp and such files should wrap their tests in a test suite called <source_filename>_tests. For an example of this pattern, examine uint256_tests.cpp.