dash/src/test
2024-04-26 20:25:31 +00:00
..
data
fuzz Merge #21377: Speedy trial support for versionbits 2024-04-23 22:41:10 +07:00
util merge bitcoin#19499: Make timeout mockable and type safe, speed up test 2024-04-26 20:25:31 +00:00
addrman_tests.cpp
allocator_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
amount_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
arith_uint256_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
base32_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
base58_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
base64_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
bech32_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
bip32_tests.cpp
bip324_tests.cpp merge bitcoin#28267: BIP324 ciphersuite follow-up 2024-03-05 21:43:22 +00:00
block_reward_reallocation_tests.cpp Merge #21377: Speedy trial support for versionbits 2024-04-23 22:41:10 +07:00
blockchain_tests.cpp
blockencodings_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
blockfilter_index_tests.cpp refactor: accept NodeContext arg into BlockAssembler instead of managers 2024-03-18 21:36:35 +00:00
blockfilter_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
bloom_tests.cpp merge bitcoin#23438: Use spans of std::byte in serialize 2024-02-28 13:37:34 -06:00
bls_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
bswap_tests.cpp Merge #21531: test: remove qt byteswap compattests 2024-04-10 03:19:40 +07:00
cachemap_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
cachemultimap_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
checkdatasig_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
checkqueue_tests.cpp
coins_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
coinstatsindex_tests.cpp Merge bitcoin/bitcoin#26188: test: silence TSAN false positive in coinstatsindex_initial_sync 2024-03-05 10:40:37 -06:00
compilerbug_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
compress_tests.cpp merge bitcoin#21817: Replace &foo[0] with foo.data() 2024-02-28 13:37:33 -06:00
crypto_tests.cpp merge bitcoin#28100: more Span<std::byte> modernization & follow-ups 2024-03-05 21:43:22 +00:00
cuckoocache_tests.cpp
dbwrapper_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
denialofservice_tests.cpp merge bitcoin#19499: Make timeout mockable and type safe, speed up test 2024-04-26 20:25:31 +00:00
descriptor_tests.cpp Merge #19136: wallet: add parent_desc to getaddressinfo 2024-04-12 12:31:49 +07:00
dip0020opcodes_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
dynamic_activation_thresholds_tests.cpp Merge #21377: Speedy trial support for versionbits 2024-04-23 22:41:10 +07:00
evo_assetlocks_tests.cpp refactor: use CTransaction for immutable tx in evo_assetlocks_tests 2024-03-24 09:21:45 +01:00
evo_deterministicmns_tests.cpp refactor: remove CDeterministicMNManager global, move to NodeContext 2024-04-16 12:55:14 -05:00
evo_mnhf_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
evo_simplifiedmns_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
evo_trivialvalidation.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
evo_utils_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
flatfile_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
fs_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
getarg_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
governance_validators_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
hash_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
i2p_tests.cpp
interfaces_tests.cpp
key_io_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
key_tests.cpp
lcg.h non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
limitedmap_tests.cpp
llmq_dkg_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
logging_tests.cpp Merge #21676: test: Use mocktime to avoid intermittent failure in rpc_tests 2024-04-11 02:26:04 +07:00
main.cpp
Makefile
mempool_tests.cpp Merge #21676: test: Use mocktime to avoid intermittent failure in rpc_tests 2024-04-11 02:26:04 +07:00
merkle_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
merkleblock_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
miner_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
multisig_tests.cpp
net_peer_eviction_tests.cpp Merge #20197: p2p: protect onions in AttemptToEvictConnection(), add eviction protection test coverage 2024-04-22 09:42:17 -05:00
net_tests.cpp Merge #20197: p2p: protect onions in AttemptToEvictConnection(), add eviction protection test coverage 2024-04-22 09:42:17 -05:00
netbase_tests.cpp merge bitcoin#21506: make NetPermissionFlags an enum class 2024-04-03 16:10:16 +00:00
pmt_tests.cpp
policyestimator_tests.cpp
pow_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
prevector_tests.cpp
raii_event_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
random_tests.cpp
ratecheck_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
README.md
reverselock_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
rpc_tests.cpp Merge #20406: util: Avoid invalid integer negation in FormatMoney and ValueFromAmount 2024-04-22 09:42:16 -05:00
sanity_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
scheduler_tests.cpp
script_p2pk_tests.cpp
script_p2pkh_tests.cpp
script_p2sh_tests.cpp
script_standard_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
script_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
scriptnum10.h
scriptnum_tests.cpp
serfloat_tests.cpp Merge bitcoin/bitcoin#22176: test: Correct outstanding -Werror=sign-compare errors 2024-02-29 09:34:59 -06: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 #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05: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 #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
subsidy_tests.cpp non-scripted-diff: bump copyright year to 2023 2024-02-24 11:05:37 -06:00
sync_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
system_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
timedata_tests.cpp
torcontrol_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
transaction_tests.cpp Merge bitcoin/bitcoin#21902: refactor: Remove useless extern keyword 2024-04-23 09:15:19 -05:00
txindex_tests.cpp Merge bitcoin/bitcoin#26188: test: silence TSAN false positive in coinstatsindex_initial_sync 2024-03-05 10:40:37 -06:00
txvalidation_tests.cpp partial bitcoin#20833: enable packages through testmempoolaccept 2024-02-02 23:14:06 -06:00
txvalidationcache_tests.cpp merge bitcoin#21062: return MempoolAcceptResult from ATMP 2024-02-02 23:14:05 -06:00
uint256_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
util_tests.cpp Merge #20406: util: Avoid invalid integer negation in FormatMoney and ValueFromAmount 2024-04-22 09:42:16 -05:00
util_threadnames_tests.cpp Merge bitcoin/bitcoin#22086: test: remove BasicTestingSetup from unit tests that don't need it 2024-03-04 00:21:21 -06:00
validation_block_tests.cpp refactor: accept NodeContext arg into BlockAssembler instead of managers 2024-03-18 21:36:35 +00:00
validation_chainstate_tests.cpp refactor: remove CMNHFManager::GetSignalsStage alias from CChainState 2024-03-18 21:36:34 +00:00
validation_chainstatemanager_tests.cpp Merge bitcoin/bitcoin#21681: validation: fix ActivateSnapshot to use hardcoded nChainTx 2024-04-23 22:41:09 +07:00
validation_flush_tests.cpp refactor: remove CMNHFManager::GetSignalsStage alias from CChainState 2024-03-18 21:36:34 +00:00
validation_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
validationinterface_tests.cpp
versionbits_tests.cpp Merge #21377: Speedy trial support for versionbits 2024-04-23 22:41:10 +07: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