• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..08-Sep-2021-

data/H03-May-2022-4,9124,564

fuzz/H08-Sep-2021-10,5998,634

util/H08-Sep-2021-1,332912

MakefileH A D08-Sep-2021115 76

README.mdH A D08-Sep-20212.9 KiB7753

addrman_tests.cppH A D08-Sep-202134.8 KiB971651

allocator_tests.cppH A D08-Sep-20217.3 KiB239194

amount_tests.cppH A D08-Sep-20214.2 KiB11785

arith_uint256_tests.cppH A D08-Sep-202122.4 KiB562476

base32_tests.cppH A D08-Sep-20211.6 KiB4230

base58_tests.cppH A D08-Sep-20214.1 KiB10178

base64_tests.cppH A D08-Sep-20211.2 KiB3927

bech32_tests.cppH A D08-Sep-20213.2 KiB10390

bip32_tests.cppH A D08-Sep-20217.1 KiB155126

blockchain_tests.cppH A D08-Sep-20212.1 KiB7853

blockencodings_tests.cppH A D08-Sep-202113.9 KiB373286

blockfilter_index_tests.cppH A D08-Sep-202111.3 KiB307231

blockfilter_tests.cppH A D08-Sep-20217.4 KiB195143

bloom_tests.cppH A D08-Sep-202146.5 KiB518347

bswap_tests.cppH A D08-Sep-2021664 2516

checkqueue_tests.cppH A D08-Sep-202113.4 KiB424342

coins_tests.cppH A D08-Sep-202137.5 KiB882662

coinstatsindex_tests.cppH A D08-Sep-20212.6 KiB8046

compilerbug_tests.cppH A D08-Sep-20211.1 KiB4330

compress_tests.cppH A D08-Sep-20214.4 KiB13892

crypto_tests.cppH A D08-Sep-202191.7 KiB951793

cuckoocache_tests.cppH A D08-Sep-202114.1 KiB372226

dbwrapper_tests.cppH A D08-Sep-202114.3 KiB416295

denialofservice_tests.cppH A D08-Sep-202116 KiB431319

descriptor_tests.cppH A D08-Sep-202169.3 KiB409301

flatfile_tests.cppH A D08-Sep-20214.1 KiB12786

fs_tests.cppH A D08-Sep-20212.9 KiB9074

getarg_tests.cppH A D08-Sep-20217.9 KiB224168

hash_tests.cppH A D08-Sep-20216.2 KiB151105

i2p_tests.cppH A D08-Sep-20211.2 KiB4529

interfaces_tests.cppH A D08-Sep-20217.1 KiB161133

key_io_tests.cppH A D08-Sep-20216.4 KiB150117

key_tests.cppH A D08-Sep-202118.3 KiB348274

logging_tests.cppH A D08-Sep-20211.1 KiB3422

main.cppH A D08-Sep-20211,010 2714

mempool_tests.cppH A D08-Sep-202132.1 KiB790549

merkle_tests.cppH A D08-Sep-202113.1 KiB352277

merkleblock_tests.cppH A D08-Sep-20212.5 KiB8142

miner_tests.cppH A D08-Sep-202126 KiB531409

multisig_tests.cppH A D08-Sep-20218.8 KiB218174

net_peer_eviction_tests.cppH A D08-Sep-202123.7 KiB553400

net_tests.cppH A D08-Sep-202131.5 KiB839633

netbase_tests.cppH A D08-Sep-202129.3 KiB578469

pmt_tests.cppH A D08-Sep-20214.3 KiB12688

policy_fee_tests.cppH A D08-Sep-2021962 3519

policyestimator_tests.cppH A D08-Sep-20217.3 KiB184127

pow_tests.cppH A D08-Sep-20217 KiB186149

prevector_tests.cppH A D08-Sep-20219 KiB296258

raii_event_tests.cppH A D08-Sep-20212.6 KiB10068

random_tests.cppH A D08-Sep-20215 KiB137115

reverselock_tests.cppH A D08-Sep-20212.2 KiB9464

rpc_tests.cppH A D08-Sep-202124.2 KiB477372

sanity_tests.cppH A D08-Sep-2021691 2213

scheduler_tests.cppH A D08-Sep-20218.2 KiB214141

script_p2sh_tests.cppH A D08-Sep-202114.2 KiB376290

script_standard_tests.cppH A D08-Sep-202118.5 KiB450345

script_tests.cppH A D08-Sep-202199.4 KiB1,7471,483

scriptnum10.hH A D08-Sep-20216.6 KiB183123

scriptnum_tests.cppH A D08-Sep-20217.2 KiB201164

serfloat_tests.cppH A D08-Sep-20214.9 KiB13093

serialize_tests.cppH A D08-Sep-202110.8 KiB289222

settings_tests.cppH A D08-Sep-20219.8 KiB259186

sighash_tests.cppH A D08-Sep-20216.7 KiB209165

sigopcount_tests.cppH A D08-Sep-202110 KiB231161

skiplist_tests.cppH A D08-Sep-20218.1 KiB191147

sock_tests.cppH A D08-Sep-20214.6 KiB181136

streams_tests.cppH A D08-Sep-202115.3 KiB460335

sync_tests.cppH A D08-Sep-20214.2 KiB144109

system_tests.cppH A D08-Sep-20213.3 KiB10174

timedata_tests.cppH A D08-Sep-20213.4 KiB10562

torcontrol_tests.cppH A D08-Sep-20216.9 KiB203157

transaction_tests.cppH A D08-Sep-202144.5 KiB961771

txindex_tests.cppH A D08-Sep-20212.8 KiB7951

txrequest_tests.cppH A D08-Sep-202131.1 KiB739502

txvalidation_tests.cppH A D08-Sep-20217.4 KiB149114

txvalidationcache_tests.cppH A D08-Sep-202117.6 KiB378244

uint256_tests.cppH A D08-Sep-202110.6 KiB289253

util_tests.cppH A D08-Sep-202193.1 KiB2,3231,840

util_threadnames_tests.cppH A D08-Sep-20211.8 KiB7341

validation_block_tests.cppH A D08-Sep-202114.1 KiB358240

validation_chainstate_tests.cppH A D08-Sep-20212.5 KiB7646

validation_chainstatemanager_tests.cppH A D08-Sep-202112.7 KiB357238

validation_flush_tests.cppH A D08-Sep-20216.2 KiB167105

validation_tests.cppH A D08-Sep-20216.1 KiB147110

validationinterface_tests.cppH A D08-Sep-20212.9 KiB9572

versionbits_tests.cppH A D08-Sep-202125.2 KiB457318

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