dash/src/test
MarcoFalke 853592e0f5 Merge #17093: tests: Add fuzzing harness for various CTx{In,Out} related functions
d5766f223f627bf2eb731ce8552dfafa2b824378 tests: Add corpora suppression (FUZZERS_MISSING_CORPORA) for fuzzers missing in https://github.com/bitcoin-core/qa-assets/tree/master/fuzz_seed_corpus (practicalswift)
e75ecb91c730115290e1201371492c2cd334e9b4 tests: Add fuzzing harness for various CTxOut related functions (practicalswift)
ce935292c041162e160d95fc6afeda3dceded2cf tests: Add fuzzing harness for various CTxIn related functions (practicalswift)

Pull request description:

  Add fuzzing harness for various `CTx{In,Out}` related functions.

  **Testing this PR**

  Run:

  ```
  $ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/tx_in
  …
  $ src/test/fuzz/tx_out
  …
  # And to to quickly verify that the relevant code regions are triggered, that the
  # fuzzing throughput seems reasonable, etc.
  $ contrib/devtools/test_fuzzing_harnesses.sh '^tx_'
  ```

  `test_fuzzing_harnesses.sh` can be found in PR #17000.

Top commit has no ACKs.

Tree-SHA512: f1374307a2581ebc3968d012ea2438061bbb84ece068e584fae9750669a6cd003723dde14db88e77c9579281ecd4eaa2a7ff0614f253d8c075e6dd16dd2e68d5
2021-09-17 15:48:14 -04:00
..
data Fix more spelling errors 2021-07-19 12:52:03 -05:00
fuzz Merge #17093: tests: Add fuzzing harness for various CTx{In,Out} related functions 2021-09-17 15:48:14 -04:00
addrman_tests.cpp Merge #15109: refactor: Use C++11 default member initializers 2021-08-10 22:20:30 -03:00
allocator_tests.cpp Merge #15114: Qt: Replace remaining 0 with nullptr 2021-08-24 19:14:50 -04:00
amount_tests.cpp Merge #14460: tests: Improve 'CAmount' tests 2021-06-28 21:05:29 -04:00
arith_uint256_tests.cpp Merge #13396: Drop unused arith_uint256 ! operator 2021-06-28 02:31:49 +03:00
base32_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
base58_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
base64_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
bech32_tests.cpp Merge #12881: Minor optimizations to bech32::Decode(); add tests. 2021-05-25 14:09:37 +03:00
bip32_tests.cpp Merge #12924: Fix hdmaster-key / seed-key confusion (scripted diff) 2021-06-28 02:00:48 +03:00
bip39_tests.cpp Merge #12924: Fix hdmaster-key / seed-key confusion (scripted diff) 2021-06-28 02:00:48 +03:00
blockchain_tests.cpp Merge #12151: rpc: Remove cs_main lock from blockToJSON and blockheaderToJSON 2021-08-24 19:16:52 -04:00
blockencodings_tests.cpp Merge #14963: mempool, validation: Explain cs_main locking semantics 2021-08-24 19:14:50 -04:00
blockfilter_index_tests.cpp bitcoin#14121: Index for BIP 157 block filters 2021-08-12 12:44:03 +05:30
blockfilter_tests.cpp bitcoin#14121: Index for BIP 157 block filters 2021-08-12 12:44:03 +05:30
bloom_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
bls_tests.cpp
bswap_tests.cpp
cachemap_tests.cpp Merge #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
cachemultimap_tests.cpp Merge #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
checkdatasig_tests.cpp
checkqueue_tests.cpp merge #16117: Replace boost sleep with std sleep 2021-08-05 16:13:47 +05:30
coins_tests.cpp Merge bitcoin#14771: test: Add BOOST_REQUIRE to getters returning optional (#4297) 2021-07-29 00:53:44 -05:00
compress_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
crypto_tests.cpp Merge #14047: Add HKDF_HMAC256_L32 and method to negate a private key 2021-08-10 23:55:56 +03:00
cuckoocache_tests.cpp Merge #14624: Some simple improvements to the RNG code 2021-07-19 19:00:04 -05:00
dbwrapper_tests.cpp Use correct datadir in all cases in dbwrapper_tests (#4348) 2021-08-24 19:18:39 +03:00
denialofservice_tests.cpp Merge #14953: test: Make g_insecure_rand_ctx thread_local 2021-08-03 18:39:34 -03:00
descriptor_tests.cpp Merge pull request #4303 from linuxsh2/backport/batch-1 2021-08-06 16:23:59 -05:00
dip0020opcodes_tests.cpp fix misc. spelling errors 2021-07-19 12:51:30 -05:00
evo_deterministicmns_tests.cpp Add missing cs_main locks/checks 2021-09-02 03:04:40 +03:00
evo_simplifiedmns_tests.cpp
flatfile_tests.cpp bitcoin#15118: Refactor block file logic 2021-08-12 12:32:29 +05:30
fs_tests.cpp merge #21052: Replace fs::unique_path with GetUniquePath(path) calls 2021-08-09 12:38:04 +05:30
getarg_tests.cpp Merge #14599: Use functions guaranteed to be locale independent (IsDigit, ToLower) in {Format,Parse}Money(...), uint256::SetHex(...), etc. Remove the use of locale dependent boost::is_space(...) 2021-09-09 11:23:24 -07:00
governance_validators_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
hash_tests.cpp tests: reenable when backporting Bitcoin #10321 (#4273) 2021-07-19 12:36:30 +03:00
key_io_tests.cpp Merge #13249: Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. 2021-07-19 17:11:18 -05:00
key_tests.cpp Merge #14047: Add HKDF_HMAC256_L32 and method to negate a private key 2021-08-10 23:55:56 +03:00
lcg.h
limitedmap_tests.cpp
logging_tests.cpp bitcoin#16805: add timing information to FlushStateToDisk() 2021-06-17 10:57: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 #14963: mempool, validation: Explain cs_main locking semantics 2021-08-24 19:14:50 -04:00
merkle_tests.cpp Merge #15139: util: Remove [U](BEGIN|END) macros 2021-08-24 19:14:49 -04:00
merkleblock_tests.cpp
miner_tests.cpp Merge #14963: mempool, validation: Explain cs_main locking semantics 2021-08-24 19:14:50 -04:00
multisig_tests.cpp Merge #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
net_tests.cpp partial Merge #14094: refactoring: Remove unreferenced local variables 2021-07-19 17:11:17 -05:00
netbase_tests.cpp Merge #20129: tests: don't export in6addr_loopback 2021-09-07 03:25:11 +03:00
pmt_tests.cpp
policyestimator_tests.cpp Merge #14963: mempool, validation: Explain cs_main locking semantics 2021-08-24 19:14:50 -04:00
pow_tests.cpp Merge #14684: [doc] conf: Remove deprecated options from docs, Other cleanup 2021-08-03 11:42:08 -04:00
prevector_tests.cpp Merge #14624: Some simple improvements to the RNG code 2021-07-19 19:00:04 -05:00
raii_event_tests.cpp Merge #16564: test: Always define the raii_event_tests test suite 2021-07-15 13:26:07 -05:00
random_tests.cpp Merge #14624: Some simple improvements to the RNG code 2021-07-19 19:00:04 -05:00
ratecheck_tests.cpp
README.md Merge #16752: doc: Delete stale URL in test README 2021-07-12 20:52:56 -05:00
reverselock_tests.cpp
rpc_tests.cpp Merge #13918: rpc: Replace median fee rate with feerate percentiles in getblockstats 2021-07-06 20:29:32 +03:00
sanity_tests.cpp
scheduler_tests.cpp Backports v0.18: PR 13743: refactor: Replace boost::bind with std::bind (#4343) 2021-08-17 23:31:09 +03:00
script_p2pk_tests.cpp
script_p2pkh_tests.cpp
script_p2sh_tests.cpp Merge #17254: test: fix script_p2sh_tests OP_PUSHBACK2/4 missing 2021-07-13 20:43:16 -05:00
script_standard_tests.cpp Merge #13491: Improve handling of INVALID in IsMine 2021-06-28 02:31:51 +03:00
script_tests.cpp Merge #13767: Remove redundant assignments (dead stores) 2021-08-03 13:57:37 -03:00
scriptnum10.h
scriptnum_tests.cpp
serialize_tests.cpp Merge #14838: Use const in COutPoint class 2021-07-08 11:57:10 -05:00
sighash_tests.cpp Merge #14838: Use const in COutPoint class 2021-07-08 11:57:10 -05:00
sigopcount_tests.cpp
skiplist_tests.cpp Merge bitcoin#14636: Avoid using numeric_limits for sequence numbers and lock times (#4296) 2021-07-28 09:16:46 -05:00
streams_tests.cpp Merge #14357: streams: Fix broken streams_vector_reader test. Remove unused seek(size_t). 2021-09-07 12:26:47 -04:00
subsidy_tests.cpp
sync_tests.cpp merge #11599: Small locking rename 2021-06-06 16:22:17 +05:30
test_dash.cpp Merge #14955: Switch all RNG code to the built-in PRNG (#4411) 2021-09-11 23:52:36 +03:00
test_dash.h Merge pull request #4333 from Munkybooty/backports-0.18-pr13 2021-08-16 14:24:51 -05:00
timedata_tests.cpp
torcontrol_tests.cpp Merge #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
transaction_tests.cpp Merge #13249: Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. 2021-07-19 17:11:18 -05:00
txindex_tests.cpp Merge #15410: test: txindex: interrupt threadGroup before calling destructor 2021-09-06 19:02:59 +05:30
txvalidation_tests.cpp Merge #13534: Don't assert(foo()) where foo() has side effects 2021-06-28 22:09:56 -04:00
txvalidationcache_tests.cpp Partial Merge #15413: tests: Add missing cs_main locks required when accessing pcoinsdbview, pcoinsTip or pblocktree 2021-09-13 16:04:35 -04:00
uint256_tests.cpp Merge #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
util_tests.cpp Merge #15139: util: Remove [U](BEGIN|END) macros 2021-08-24 19:14:49 -04:00
util_threadnames_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
validation_block_tests.cpp Merge #14985: test: Remove thread_local from test_bitcoin 2021-08-15 11:08:08 -04:00
validation_tests.cpp bitcoin#15504: Link BasicTestingSetup (shared with unit tests) 2021-08-11 09:48:40 +05:30
versionbits_tests.cpp Merge #13555: Tests: parameterize adjustment period in versionbits_computeblockversion 2021-07-12 17:11:08 -05:00

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 test_dash.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.