dash/src/test
2024-09-04 16:29:29 +00:00
..
data Merge #19698: test: apply strict verification flags for transaction tests and assert backwards compatibility 2024-06-20 12:23:13 +07:00
fuzz merge bitcoin#24021: Rename and move PoissonNextSend functions 2024-09-04 16:29:29 +00:00
util Merge #6234: backport: bitcoin#21178, #22089, #22130, #22210, #22216, bitcoin-core/gui#361, partial: bitcoin#14123 2024-09-03 09:27:22 -05:00
addrman_tests.cpp fix: Let addrman handle multiple ports for all networks 2024-06-14 22:04:55 +03:00
allocator_tests.cpp
amount_tests.cpp Merge bitcoin/bitcoin#21848: refactor: Make CFeeRate constructor architecture-independent 2024-05-24 13:24:30 -05:00
arith_uint256_tests.cpp
base32_tests.cpp
base58_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
base64_tests.cpp
bech32_tests.cpp
bip32_tests.cpp
bip324_tests.cpp
block_reward_reallocation_tests.cpp feat: put brr activation to height=1 2024-08-15 11:27:20 +07:00
blockchain_tests.cpp
blockencodings_tests.cpp merge bitcoin#25147: follow ups to #20799 (removing support for v1 compact blocks) 2024-06-10 17:31:24 +00:00
blockfilter_index_tests.cpp refactor: remove unused includes from unit tests 2024-07-13 00:13:10 +07:00
blockfilter_tests.cpp
bloom_tests.cpp
bls_tests.cpp
bswap_tests.cpp
cachemap_tests.cpp
cachemultimap_tests.cpp
checkdatasig_tests.cpp
checkqueue_tests.cpp
coins_tests.cpp merge bitcoin#26999: A few follow-ups to bitcoin#17487 2024-08-23 06:57:38 +00:00
coinstatsindex_tests.cpp merge bitcoin#21866: Farewell, global Chainstate! 2024-06-26 13:50:50 +00:00
compilerbug_tests.cpp
compress_tests.cpp
crypto_tests.cpp
cuckoocache_tests.cpp
dbwrapper_tests.cpp Merge bitcoin/bitcoin#24338: util: Work around libstdc++ create_directories issue 2024-08-14 12:47:45 +07:00
denialofservice_tests.cpp merge bitcoin#24543: Move remaining globals into PeerManagerImpl 2024-09-04 16:29:29 +00:00
descriptor_tests.cpp merge bitcoin#20867: Support up to 20 keys for multisig under Segwit context 2024-06-27 19:27:37 +00:00
dip0020opcodes_tests.cpp
dynamic_activation_thresholds_tests.cpp refactor: remove unused includes from unit tests 2024-07-13 00:13:10 +07:00
evo_assetlocks_tests.cpp merge bitcoin#21866: Farewell, global Chainstate! 2024-06-26 13:50:50 +00:00
evo_deterministicmns_tests.cpp merge bitcoin#21526: UpdateTip/CheckBlockIndex assumeutxo support 2024-07-19 17:17:47 +00:00
evo_mnhf_tests.cpp
evo_simplifiedmns_tests.cpp
evo_trivialvalidation.cpp
evo_utils_tests.cpp
flatfile_tests.cpp merge bitcoin#21850: Remove GetDataDir(net_specific) function 2024-07-23 17:45:24 +00:00
fs_tests.cpp Merge bitcoin/bitcoin#24338: util: Work around libstdc++ create_directories issue 2024-08-14 12:47:45 +07:00
getarg_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
governance_validators_tests.cpp
hash_tests.cpp
i2p_tests.cpp merge bitcoin#21850: Remove GetDataDir(net_specific) function 2024-07-23 17:45:24 +00:00
interfaces_tests.cpp merge bitcoin#22932: Add CBlockIndex lock annotations, guard nStatus/nFile/nDataPos/nUndoPos by cs_main 2024-07-19 17:17:48 +00:00
key_io_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
key_tests.cpp Merge bitcoin/bitcoin#24213: refactor: use Span in random.* 2024-06-06 22:58:30 -05:00
lcg.h
limitedmap_tests.cpp
llmq_dkg_tests.cpp
logging_tests.cpp Merge bitcoin/bitcoin#22904: sync, log: inline lock contention logging macro to fix duration, improve BCLog::LogMsg() 2024-06-04 12:51:04 -05:00
main.cpp merge bitcoin#24301: header-only Boost 2024-08-13 22:53:48 +07:00
Makefile
mempool_tests.cpp
merkle_tests.cpp
merkleblock_tests.cpp
miner_tests.cpp Merge bitcoin/bitcoin#22277: test: Properly set BIP34 height in CreateNewBlock_validity unit test 2024-07-25 10:44:24 -05:00
multisig_tests.cpp
net_peer_eviction_tests.cpp merge bitcoin#23758: Use type-safe mockable time for peer connection time 2024-06-12 16:37:11 +00:00
net_tests.cpp merge bitcoin#25514: Move CNode::nServices and CNode::nLocalServices to Peer 2024-08-09 17:34:41 +07:00
netbase_tests.cpp merge bitcoin#23077: Full CJDNS support 2024-05-29 18:07:44 +00:00
pmt_tests.cpp
policyestimator_tests.cpp
pow_tests.cpp
prevector_tests.cpp
raii_event_tests.cpp
random_tests.cpp Merge bitcoin/bitcoin#26827: doc: use "std lib clock" over "C++11 clock" 2024-08-12 11:52:41 +07:00
ratecheck_tests.cpp
README.md
reverselock_tests.cpp
rpc_tests.cpp Merge #21574: Drop JSONRPCRequest constructors after #21366 2024-07-16 00:25:06 +07:00
sanity_tests.cpp
scheduler_tests.cpp
script_p2pk_tests.cpp
script_p2pkh_tests.cpp
script_p2sh_tests.cpp
script_standard_tests.cpp Merge bitcoin/bitcoin#21840: test: Misc refactor to get rid of &foo[0] raw pointers 2024-07-26 23:40:04 +07:00
script_tests.cpp merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System 2024-08-06 18:00:39 +00:00
scriptnum10.h
scriptnum_tests.cpp
serfloat_tests.cpp merge bitcoin#22633: Replace remaining binascii method calls 2024-07-23 17:45:24 +00:00
serialize_tests.cpp merge bitcoin#24406: Fix Wambiguous-reversed-operator compiler warnings 2024-04-23 15:34:50 +00:00
settings_tests.cpp merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System 2024-08-06 18:00:39 +00:00
sighash_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
sigopcount_tests.cpp
skiplist_tests.cpp
sock_tests.cpp
streams_tests.cpp merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System 2024-08-06 18:00:39 +00:00
subsidy_tests.cpp
sync_tests.cpp
system_tests.cpp
timedata_tests.cpp partial bitcoin#20196: fix GetListenPort() to derive the proper port 2024-04-26 20:25:31 +00:00
torcontrol_tests.cpp
transaction_tests.cpp Merge bitcoin/bitcoin#22860: test: Always clear reject reason in IsStandard tx test 2024-08-22 10:00:01 -05:00
txindex_tests.cpp merge bitcoin#21866: Farewell, global Chainstate! 2024-06-26 13:50:50 +00:00
txvalidation_tests.cpp feat: enforce DIP0001 from first block on regtest and drop fDIP0001ActiveAtTip 2024-08-16 10:57:48 +07:00
txvalidationcache_tests.cpp Merge bitcoin/bitcoin#22818: test: Activate all regtest softforks at height 1, unless overridden 2024-08-14 16:58:46 +07:00
uint256_tests.cpp
util_tests.cpp Merge bitcoin/bitcoin#24251: Re-enable windows path tests disabled by #20744 2024-08-14 12:47:45 +07:00
util_threadnames_tests.cpp
validation_block_tests.cpp Merge bitcoin/bitcoin#16333: test: Set BIP34Height = 2 for regtest 2024-08-12 11:43:36 +07:00
validation_chainstate_tests.cpp merge bitcoin#22564: Move mutable globals cleared in ::UnloadBlockIndex to BlockManager 2024-08-23 06:57:37 +00:00
validation_chainstatemanager_tests.cpp merge bitcoin#22564: Move mutable globals cleared in ::UnloadBlockIndex to BlockManager 2024-08-23 06:57:37 +00:00
validation_flush_tests.cpp Merge #6085: backport: merge bitcoin#21727, #22371, #21526, #23174, #23785, #23581, #23974, #22932, #24050, #24515 (blockstorage backports) 2024-07-23 09:30:59 -05:00
validation_tests.cpp merge bitcoin#21953: fuzz: Add utxo_snapshot target 2024-07-23 17:45:24 +00:00
validationinterface_tests.cpp
versionbits_tests.cpp Merge bitcoin/bitcoin#24032: Add defaults to vDeployments to avoid uninitialized variables 2024-07-24 14:04:29 -05:00
xoroshiro128plusplus_tests.cpp

Unit tests

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 set up to compile an executable called test_dash that runs all of the unit tests. The main source file for the test library is found in util/setup_common.cpp.

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 unit 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 unit tests.

To add more unit 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 GUI unit tests manually, launch src/qt/test/test_dash-qt

To add more GUI unit 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 -- DEBUG_LOG_OUT

log_level controls the verbosity of the test framework, which logs when a test case is entered, for example. The DEBUG_LOG_OUT after the two dashes redirects the debug log, which would normally go to a file in the test datadir (BasicTestingSetup::m_path_root), to the standard terminal output.

... or to run just the doubledash test:

test_dash --run_test=getarg_tests/doubledash

Run test_dash --help for the full list.

Adding test cases

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, see uint256_tests.cpp.

Logging and debugging in unit tests

make check will write to a log file foo_tests.cpp.log and display this file on failure. For running individual tests verbosely, refer to the section above.

To write to logs from unit tests you need to use specific message methods provided by Boost. The simplest is BOOST_TEST_MESSAGE.

For debugging you can launch the test_dash executable with gdbor lldb and start debugging, just like you would with any other program:

gdb src/test/test_dash