|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 08-Sep-2021 | - |
| data/ | H | 03-May-2022 | - | 4,912 | 4,564 |
| fuzz/ | H | 08-Sep-2021 | - | 10,599 | 8,634 |
| util/ | H | 08-Sep-2021 | - | 1,332 | 912 |
| Makefile | H A D | 08-Sep-2021 | 115 | 7 | 6 |
| README.md | H A D | 08-Sep-2021 | 2.9 KiB | 77 | 53 |
| addrman_tests.cpp | H A D | 08-Sep-2021 | 34.8 KiB | 971 | 651 |
| allocator_tests.cpp | H A D | 08-Sep-2021 | 7.3 KiB | 239 | 194 |
| amount_tests.cpp | H A D | 08-Sep-2021 | 4.2 KiB | 117 | 85 |
| arith_uint256_tests.cpp | H A D | 08-Sep-2021 | 22.4 KiB | 562 | 476 |
| base32_tests.cpp | H A D | 08-Sep-2021 | 1.6 KiB | 42 | 30 |
| base58_tests.cpp | H A D | 08-Sep-2021 | 4.1 KiB | 101 | 78 |
| base64_tests.cpp | H A D | 08-Sep-2021 | 1.2 KiB | 39 | 27 |
| bech32_tests.cpp | H A D | 08-Sep-2021 | 3.2 KiB | 103 | 90 |
| bip32_tests.cpp | H A D | 08-Sep-2021 | 7.1 KiB | 155 | 126 |
| blockchain_tests.cpp | H A D | 08-Sep-2021 | 2.1 KiB | 78 | 53 |
| blockencodings_tests.cpp | H A D | 08-Sep-2021 | 13.9 KiB | 373 | 286 |
| blockfilter_index_tests.cpp | H A D | 08-Sep-2021 | 11.3 KiB | 307 | 231 |
| blockfilter_tests.cpp | H A D | 08-Sep-2021 | 7.4 KiB | 195 | 143 |
| bloom_tests.cpp | H A D | 08-Sep-2021 | 46.5 KiB | 518 | 347 |
| bswap_tests.cpp | H A D | 08-Sep-2021 | 664 | 25 | 16 |
| checkqueue_tests.cpp | H A D | 08-Sep-2021 | 13.4 KiB | 424 | 342 |
| coins_tests.cpp | H A D | 08-Sep-2021 | 37.5 KiB | 882 | 662 |
| coinstatsindex_tests.cpp | H A D | 08-Sep-2021 | 2.6 KiB | 80 | 46 |
| compilerbug_tests.cpp | H A D | 08-Sep-2021 | 1.1 KiB | 43 | 30 |
| compress_tests.cpp | H A D | 08-Sep-2021 | 4.4 KiB | 138 | 92 |
| crypto_tests.cpp | H A D | 08-Sep-2021 | 91.7 KiB | 951 | 793 |
| cuckoocache_tests.cpp | H A D | 08-Sep-2021 | 14.1 KiB | 372 | 226 |
| dbwrapper_tests.cpp | H A D | 08-Sep-2021 | 14.3 KiB | 416 | 295 |
| denialofservice_tests.cpp | H A D | 08-Sep-2021 | 16 KiB | 431 | 319 |
| descriptor_tests.cpp | H A D | 08-Sep-2021 | 69.3 KiB | 409 | 301 |
| flatfile_tests.cpp | H A D | 08-Sep-2021 | 4.1 KiB | 127 | 86 |
| fs_tests.cpp | H A D | 08-Sep-2021 | 2.9 KiB | 90 | 74 |
| getarg_tests.cpp | H A D | 08-Sep-2021 | 7.9 KiB | 224 | 168 |
| hash_tests.cpp | H A D | 08-Sep-2021 | 6.2 KiB | 151 | 105 |
| i2p_tests.cpp | H A D | 08-Sep-2021 | 1.2 KiB | 45 | 29 |
| interfaces_tests.cpp | H A D | 08-Sep-2021 | 7.1 KiB | 161 | 133 |
| key_io_tests.cpp | H A D | 08-Sep-2021 | 6.4 KiB | 150 | 117 |
| key_tests.cpp | H A D | 08-Sep-2021 | 18.3 KiB | 348 | 274 |
| logging_tests.cpp | H A D | 08-Sep-2021 | 1.1 KiB | 34 | 22 |
| main.cpp | H A D | 08-Sep-2021 | 1,010 | 27 | 14 |
| mempool_tests.cpp | H A D | 08-Sep-2021 | 32.1 KiB | 790 | 549 |
| merkle_tests.cpp | H A D | 08-Sep-2021 | 13.1 KiB | 352 | 277 |
| merkleblock_tests.cpp | H A D | 08-Sep-2021 | 2.5 KiB | 81 | 42 |
| miner_tests.cpp | H A D | 08-Sep-2021 | 26 KiB | 531 | 409 |
| multisig_tests.cpp | H A D | 08-Sep-2021 | 8.8 KiB | 218 | 174 |
| net_peer_eviction_tests.cpp | H A D | 08-Sep-2021 | 23.7 KiB | 553 | 400 |
| net_tests.cpp | H A D | 08-Sep-2021 | 31.5 KiB | 839 | 633 |
| netbase_tests.cpp | H A D | 08-Sep-2021 | 29.3 KiB | 578 | 469 |
| pmt_tests.cpp | H A D | 08-Sep-2021 | 4.3 KiB | 126 | 88 |
| policy_fee_tests.cpp | H A D | 08-Sep-2021 | 962 | 35 | 19 |
| policyestimator_tests.cpp | H A D | 08-Sep-2021 | 7.3 KiB | 184 | 127 |
| pow_tests.cpp | H A D | 08-Sep-2021 | 7 KiB | 186 | 149 |
| prevector_tests.cpp | H A D | 08-Sep-2021 | 9 KiB | 296 | 258 |
| raii_event_tests.cpp | H A D | 08-Sep-2021 | 2.6 KiB | 100 | 68 |
| random_tests.cpp | H A D | 08-Sep-2021 | 5 KiB | 137 | 115 |
| reverselock_tests.cpp | H A D | 08-Sep-2021 | 2.2 KiB | 94 | 64 |
| rpc_tests.cpp | H A D | 08-Sep-2021 | 24.2 KiB | 477 | 372 |
| sanity_tests.cpp | H A D | 08-Sep-2021 | 691 | 22 | 13 |
| scheduler_tests.cpp | H A D | 08-Sep-2021 | 8.2 KiB | 214 | 141 |
| script_p2sh_tests.cpp | H A D | 08-Sep-2021 | 14.2 KiB | 376 | 290 |
| script_standard_tests.cpp | H A D | 08-Sep-2021 | 18.5 KiB | 450 | 345 |
| script_tests.cpp | H A D | 08-Sep-2021 | 99.4 KiB | 1,747 | 1,483 |
| scriptnum10.h | H A D | 08-Sep-2021 | 6.6 KiB | 183 | 123 |
| scriptnum_tests.cpp | H A D | 08-Sep-2021 | 7.2 KiB | 201 | 164 |
| serfloat_tests.cpp | H A D | 08-Sep-2021 | 4.9 KiB | 130 | 93 |
| serialize_tests.cpp | H A D | 08-Sep-2021 | 10.8 KiB | 289 | 222 |
| settings_tests.cpp | H A D | 08-Sep-2021 | 9.8 KiB | 259 | 186 |
| sighash_tests.cpp | H A D | 08-Sep-2021 | 6.7 KiB | 209 | 165 |
| sigopcount_tests.cpp | H A D | 08-Sep-2021 | 10 KiB | 231 | 161 |
| skiplist_tests.cpp | H A D | 08-Sep-2021 | 8.1 KiB | 191 | 147 |
| sock_tests.cpp | H A D | 08-Sep-2021 | 4.6 KiB | 181 | 136 |
| streams_tests.cpp | H A D | 08-Sep-2021 | 15.3 KiB | 460 | 335 |
| sync_tests.cpp | H A D | 08-Sep-2021 | 4.2 KiB | 144 | 109 |
| system_tests.cpp | H A D | 08-Sep-2021 | 3.3 KiB | 101 | 74 |
| timedata_tests.cpp | H A D | 08-Sep-2021 | 3.4 KiB | 105 | 62 |
| torcontrol_tests.cpp | H A D | 08-Sep-2021 | 6.9 KiB | 203 | 157 |
| transaction_tests.cpp | H A D | 08-Sep-2021 | 44.5 KiB | 961 | 771 |
| txindex_tests.cpp | H A D | 08-Sep-2021 | 2.8 KiB | 79 | 51 |
| txrequest_tests.cpp | H A D | 08-Sep-2021 | 31.1 KiB | 739 | 502 |
| txvalidation_tests.cpp | H A D | 08-Sep-2021 | 7.4 KiB | 149 | 114 |
| txvalidationcache_tests.cpp | H A D | 08-Sep-2021 | 17.6 KiB | 378 | 244 |
| uint256_tests.cpp | H A D | 08-Sep-2021 | 10.6 KiB | 289 | 253 |
| util_tests.cpp | H A D | 08-Sep-2021 | 93.1 KiB | 2,323 | 1,840 |
| util_threadnames_tests.cpp | H A D | 08-Sep-2021 | 1.8 KiB | 73 | 41 |
| validation_block_tests.cpp | H A D | 08-Sep-2021 | 14.1 KiB | 358 | 240 |
| validation_chainstate_tests.cpp | H A D | 08-Sep-2021 | 2.5 KiB | 76 | 46 |
| validation_chainstatemanager_tests.cpp | H A D | 08-Sep-2021 | 12.7 KiB | 357 | 238 |
| validation_flush_tests.cpp | H A D | 08-Sep-2021 | 6.2 KiB | 167 | 105 |
| validation_tests.cpp | H A D | 08-Sep-2021 | 6.1 KiB | 147 | 110 |
| validationinterface_tests.cpp | H A D | 08-Sep-2021 | 2.9 KiB | 95 | 72 |
| versionbits_tests.cpp | H A D | 08-Sep-2021 | 25.2 KiB | 457 | 318 |
README.md
1# Unit tests
2
3The sources in this directory are unit test cases. Boost includes a
4unit testing framework, and since Bitcoin Core already uses Boost, it makes
5sense to simply use this framework rather than require developers to
6configure some other framework (we want as few impediments to creating
7unit tests as possible).
8
9The build system is set up to compile an executable called `test_bitcoin`
10that runs all of the unit tests. The main source file for the test library is found in
11`util/setup_common.cpp`.
12
13### Compiling/running unit tests
14
15Unit tests will be automatically compiled if dependencies were met in `./configure`
16and tests weren't explicitly disabled.
17
18After configuring, they can be run with `make check`.
19
20To run the unit tests manually, launch `src/test/test_bitcoin`. To recompile
21after a test file was modified, run `make` and then run the test again. If you
22modify a non-test file, use `make -C src/test` to recompile only what's needed
23to run the unit tests.
24
25To add more unit tests, add `BOOST_AUTO_TEST_CASE` functions to the existing
26.cpp files in the `test/` directory or add new .cpp files that
27implement new `BOOST_AUTO_TEST_SUITE` sections.
28
29To run the GUI unit tests manually, launch `src/qt/test/test_bitcoin-qt`
30
31To add more GUI unit tests, add them to the `src/qt/test/` directory and
32the `src/qt/test/test_main.cpp` file.
33
34### Running individual tests
35
36`test_bitcoin` has some built-in command-line arguments; for
37example, to run just the `getarg_tests` verbosely:
38
39 test_bitcoin --log_level=all --run_test=getarg_tests -- DEBUG_LOG_OUT
40
41`log_level` controls the verbosity of the test framework, which logs when a
42test case is entered, for example. The `DEBUG_LOG_OUT` after the two dashes
43redirects the debug log, which would normally go to a file in the test datadir
44(`BasicTestingSetup::m_path_root`), to the standard terminal output.
45
46... or to run just the doubledash test:
47
48 test_bitcoin --run_test=getarg_tests/doubledash
49
50Run `test_bitcoin --help` for the full list.
51
52### Adding test cases
53
54To add a new unit test file to our test suite you need
55to add the file to `src/Makefile.test.include`. The pattern is to create
56one test file for each class or source file for which you want to create
57unit tests. The file naming convention is `<source_filename>_tests.cpp`
58and such files should wrap their tests in a test suite
59called `<source_filename>_tests`. For an example of this pattern,
60see `uint256_tests.cpp`.
61
62### Logging and debugging in unit tests
63
64`make check` will write to a log file `foo_tests.cpp.log` and display this file
65on failure. For running individual tests verbosely, refer to the section
66[above](#running-individual-tests).
67
68To write to logs from unit tests you need to use specific message methods
69provided by Boost. The simplest is `BOOST_TEST_MESSAGE`.
70
71For debugging you can launch the `test_bitcoin` executable with `gdb`or `lldb` and
72start debugging, just like you would with any other program:
73
74```bash
75gdb src/test/test_bitcoin
76```
77