dash/src/test
Wladimir J. van der Laan 56cd5d3c97 Merge #17758: Fix CNetAddr::IsRFC2544 comment + tests
529d332fbfe633d60845a97e1a06f552bd63d0d4 test: add IsRFC2544 tests (Mark Tyneway)
419ef3b7cc04e3ab26252d7024da847dfd5ab1a3 CNetAddr: fix IsRFC2544 comment (Mark Tyneway)

Pull request description:

  The comment describing the functionality of `CNetAddr::IsRFC2544` is incorrect.

  46d6930f8c/src/netaddress.h (L57)

  It should actually read `198.18.0.0/15` based on [RFC 3330](https://tools.ietf.org/html/rfc3330):

  ```
     198.18.0.0/15 - This block has been allocated for use in benchmark
     tests of network interconnect devices.  Its use is documented in
     [RFC2544].
  ```

  See [RFC 2544](https://tools.ietf.org/html/rfc2544) here.

  See the implementation here:

  47d981e827/src/netaddress.cpp (L142-L145)

  This PR also adds tests for the minimum and maximum values that are valid RFC 2544 addresses.

ACKs for top commit:
  practicalswift:
    ACK 529d332fbfe633d60845a97e1a06f552bd63d0d4
  laanwj:
    ACK 529d332fbfe633d60845a97e1a06f552bd63d0d4
  promag:
    ACK 529d332fbfe633d60845a97e1a06f552bd63d0d4, nit could squash.
  jonatack:
    ACK 529d332fbfe633d60845a97e1a06f552bd63d0d4

Tree-SHA512: 954a9582856d77564e0ea5fd2e3d287d0cfc4ecfe0588115692d01005e8ca7ad8ab20ff390ded867dc91af2bfb758d4e73a336e6c0b7798846c30a6d69b8ae3d
2021-07-15 11:07:35 -05:00
..
data Merge #13255: trivial: Fixed typos and cleaned up language 2021-07-02 12:59:29 +03:00
addrman_tests.cpp Merge #16422: test: remove redundant setup in addrman_tests 2021-07-12 20:16:37 -05:00
allocator_tests.cpp Merge #14287: tests: Use MakeUnique to construct objects owned by unique_ptrs 2021-06-28 21:05:29 -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 #13163: Make it clear which functions that are intended to be translation unit local 2021-05-25 14:09:36 +03:00
blockencodings_tests.cpp partial merge #18317: Serialization improvements step 6 (all except wallet/gui) 2021-05-28 11:39:24 +03:00
blockfilter_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
bloom_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
bls_tests.cpp tests: Add more unit tests for bls/bls.cpp (#4118) 2021-04-27 17:10:43 +03:00
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 #14287: tests: Use MakeUnique to construct objects owned by unique_ptrs 2021-06-28 21:05:29 -04:00
coins_tests.cpp Merge #16225: tests: Make coins_tests/updatecoins_simulation_test deterministic 2021-07-12 20:16:37 -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 pull request #4239 from Munkybooty/backports-0.18-pr7 2021-07-13 11:51:50 -05:00
cuckoocache_tests.cpp Merge #16986: doc: Doxygen-friendly CuckooCache comments 2021-07-13 13:14:08 -05:00
dbwrapper_tests.cpp Merge #17641: Add unit test for leveldb creation with unicode path 2021-07-15 11:07:17 -05:00
denialofservice_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
dip0020opcodes_tests.cpp
evo_deterministicmns_tests.cpp evo: Fix two mempool issues (#4154) 2021-05-14 12:55:03 -05:00
evo_simplifiedmns_tests.cpp
fs_tests.cpp Merge #17086: tests: Fix fs_tests for unknown locales 2021-06-24 23:43:05 +05:30
getarg_tests.cpp Merge #13112: Throw an error for unknown args 2021-06-28 02:00:50 +03:00
governance_validators_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
hash_tests.cpp merge bitcoin#14074: Use std::unordered_set instead of set in blockfilter interface 2021-06-27 12:03:15 +05:30
key_io_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
key_tests.cpp Merge #13666: Always create signatures with Low R values 2021-07-06 20:29:32 +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_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
Makefile
mempool_tests.cpp Merge #13457: tests: Drop variadic macro 2021-06-28 02:31:50 +03:00
merkle_tests.cpp Partial #19326: Simplify hash.h interface using Spans 2021-05-20 10:15:17 +05:30
merkleblock_tests.cpp Merge #12920: test: Fix sign for expected values 2021-04-17 16:22:01 -04:00
miner_tests.cpp Merge #13083: Add compile time checking for cs_main runtime locking assertions 2021-07-07 16:30:58 -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 Merge #14287: tests: Use MakeUnique to construct objects owned by unique_ptrs 2021-06-28 21:05:29 -04:00
netbase_tests.cpp Merge #17758: Fix CNetAddr::IsRFC2544 comment + tests 2021-07-15 11:07:35 -05:00
pmt_tests.cpp
policyestimator_tests.cpp merge bitcoin#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
pow_tests.cpp Merge #16931: test: add unittests for CheckProofOfWork 2021-07-13 13:14:03 -05:00
prevector_tests.cpp
raii_event_tests.cpp
random_tests.cpp Merge #12920: test: Fix sign for expected values 2021-04-17 16:22:01 -04:00
ratecheck_tests.cpp Update copyright (#4115) 2021-04-20 22:33:02 +03:00
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 Merge #14088: tests: Don't assert(...) with side effects 2021-07-01 16:33:23 -05:00
script_p2pk_tests.cpp Update copyright (#4115) 2021-04-20 22:33:02 +03:00
script_p2pkh_tests.cpp
script_p2sh_tests.cpp Merge #15099: tests: Use std::vector API for construction of test data 2021-06-28 13:40:52 -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 pull request #4234 from UdjinM6/backports-0.17-pr35 2021-07-10 12:11:49 +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#14555: Move util files to directory 2021-06-27 12:03:13 +05:30
streams_tests.cpp Merge #16577: util: CBufferedFile fixes and unit test 2021-07-13 13:03:30 -05:00
subsidy_tests.cpp Update copyright (#4115) 2021-04-20 22:33:02 +03:00
sync_tests.cpp merge #11599: Small locking rename 2021-06-06 16:22:17 +05:30
test_dash_fuzzy.cpp Merge #13961: util: Replace boost::signals2 with std::function 2021-06-28 22:09:56 -04:00
test_dash_main.cpp
test_dash.cpp Merge #13243: Make reusable base class for auxiliary indices 2021-07-02 00:42:14 +03:00
test_dash.h Merge #14244: amount: Move CAmount CENT to unit test header 2021-07-01 16:57:02 -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 #17555: test: add unit test for non-standard txs with wrong nVersion 2021-07-15 11:07:35 -05:00
txindex_tests.cpp Merge #14085: index: Fix for indexers skipping genesis block. 2021-07-02 00:42:18 +03:00
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 Merge #13404: [tests] speed up of tx_validationcache_tests by reusing of CTransaction. 2021-06-28 02:31:49 +03: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 #13112: Throw an error for unknown args 2021-06-28 02:00:50 +03: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 #13282: trivial: Mark overrides as such. 2021-06-05 22:13:02 +03:00
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.