dash/src/test
2024-05-26 22:26:56 +00:00
..
data feat: improving unit tests for Basic BLS and enforcing Basic BLS for Evo Nodes (#5463) 2023-11-08 10:30:39 -06:00
fuzz merge bitcoin#21261: update inbound eviction protection for multiple networks, add I2P peers 2024-05-26 22:26:56 +00:00
util merge bitcoin#21261: update inbound eviction protection for multiple networks, add I2P peers 2024-05-26 22:26:56 +00:00
addrman_tests.cpp Merge bitcoin/bitcoin#22505: addrman: Remove unused test_before_evict argument from Good() 2023-12-03 20:13:09 -06:00
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 bitcoin/bitcoin#21848: refactor: Make CFeeRate constructor architecture-independent 2024-05-24 13:24:30 -05: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 Merge bitcoin/bitcoin#22836: Stricter BIP32 decoding and test vector 5 2023-12-26 22:26:18 -06:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
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 Merge bitcoin/bitcoin#25017: validation: make CScriptCheck and prevector swap members noexcept 2024-01-13 19:32:32 -06:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
dbwrapper_tests.cpp Merge #21244: Move GetDataDir to ArgsManager 2024-04-16 09:20:32 -05:00
denialofservice_tests.cpp merge bitcoin#21167: make CNode::m_inbound_onion public, initialize explicitly 2024-05-08 16:20:18 +00:00
descriptor_tests.cpp Merge bitcoin/bitcoin#21329: descriptor wallet: Cache last hardened xpub and use in normalized descriptors 2024-05-10 14:02:01 +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 merge bitcoin#21387: Refactor sock to add I2P fuzz and unit tests 2023-07-24 20:45:49 +03:00
interfaces_tests.cpp Merge #18660: test: Verify findCommonAncestor always initializes outputs 2023-07-24 11:42:34 -05: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 #20248: test: fix length of R check in key_signature_tests 2023-12-03 20:44:54 -06:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
net_peer_eviction_tests.cpp merge bitcoin#21261: update inbound eviction protection for multiple networks, add I2P peers 2024-05-26 22:26:56 +00:00
net_tests.cpp merge bitcoin#21167: make CNode::m_inbound_onion public, initialize explicitly 2024-05-08 16:20:18 +00:00
netbase_tests.cpp merge bitcoin#21506: make NetPermissionFlags an enum class 2024-04-03 16:10:16 +00:00
pmt_tests.cpp Merge bitcoin/bitcoin#24854: Remove not needed ArithToUint256 roundtrips in tests 2024-01-13 19:32:31 -06:00
policyestimator_tests.cpp Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
pow_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
prevector_tests.cpp Merge bitcoin/bitcoin#25017: validation: make CScriptCheck and prevector swap members noexcept 2024-01-13 19:32:32 -06:00
raii_event_tests.cpp Merge #20813: scripted-diff: Bump copyright headers 2024-04-10 03:19:34 +07:00
random_tests.cpp Merge #18216: test, build: Enable -Werror=sign-compare 2024-01-06 19:30:13 -06:00
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 Merge bitcoin/bitcoin#25040: refactor: Pass lifetimebound reference to SingleThreadedSchedulerClient 2024-01-13 23:09:41 -06:00
script_p2pk_tests.cpp
script_p2pkh_tests.cpp
script_p2sh_tests.cpp Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
scriptnum_tests.cpp Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
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 Merge #18673: scripted-diff: Sort test includes 2023-08-29 22:00:59 -05:00
skiplist_tests.cpp
sock_tests.cpp Merge bitcoin/bitcoin#21659: net: flag relevant Sock methods with [[nodiscard]] 2023-12-03 20:44:59 -06:00
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 partial bitcoin#20196: fix GetListenPort() to derive the proper port 2024-04-26 20:25:31 +00:00
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 Merge #18975: test: Remove const to work around compiler error on xenial 2024-01-09 08:13:03 -06:00
versionbits_tests.cpp Merge #21377: Speedy trial support for versionbits 2024-04-23 22:41:10 +07:00
xoroshiro128plusplus_tests.cpp Merge bitcoin/bitcoin#26153: Reduce wasted pseudorandom bytes in ChaCha20 + various improvements 2023-11-19 10:20:12 -06:00

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