You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
litecoin/src/test
David Burkett eef63f7034
v0.21.2
2 years ago
..
data Test fixes 3 years ago
fuzz Support partial rewind of outputs for locked wallets, and UpgradeCoins() function to finish rewinding once unlocked. 2 years ago
util Litecoin: HRPs 3 years ago
Makefile
README.md Litecoin: Branding 3 years ago
addrman_tests.cpp [addrman] Specify max addresses and pct when calling GetAddresses() 4 years ago
allocator_tests.cpp scripted-diff: test: Move setup_common to test library 5 years ago
amount_tests.cpp MWEB: Included MWEB weight in feerate 2 years ago
arith_uint256_tests.cpp test: Move boost/stdlib includes last 4 years ago
base32_tests.cpp net: recognize TORv3/I2P/CJDNS networks 4 years ago
base58_tests.cpp util: make EncodeBase58 consume Spans 4 years ago
base64_tests.cpp scripted-diff: Bump copyright headers 4 years ago
bech32_tests.cpp Add Bech32m test vectors 3 years ago
bip32_tests.cpp scripted-diff: Bump copyright headers 4 years ago
blockchain_tests.cpp scripted-diff: Bump copyright headers 4 years ago
blockencodings_tests.cpp Litecoin: Fix various tests 3 years ago
blockfilter_index_tests.cpp Litecoin: scrypt changes 3 years ago
blockfilter_tests.cpp MWEB: Pegout maturity 2 years ago
bloom_tests.cpp Litecoin: Fix various tests 3 years ago
bswap_tests.cpp scripted-diff: Bump copyright headers 4 years ago
checkqueue_tests.cpp refactor: Specify boost/thread/thread.hpp explicitly 4 years ago
coins_tests.cpp MWEB: Pegout maturity 2 years ago
compilerbug_tests.cpp scripted-diff: Bump copyright headers 4 years ago
compress_tests.cpp Litecoin: Protocol and default settings 3 years ago
crypto_tests.cpp Implement keccak-f[1600] and SHA3-256 4 years ago
cuckoocache_tests.cpp scripted-diff: Bump copyright headers 4 years ago
dbwrapper_tests.cpp Merge #18317: Serialization improvements step 6 (all except wallet/gui) 4 years ago
denialofservice_tests.cpp test: make sure non-IP peers get discouraged and disconnected 3 years ago
descriptor_tests.cpp MWEB: Wallet & UI changes 2 years ago
flatfile_tests.cpp test: Fix outstanding -Wsign-compare errors 4 years ago
fs_tests.cpp scripted-diff: test: Move setup_common to test library 5 years ago
getarg_tests.cpp Litecoin: Branding 3 years ago
hash_tests.cpp scripted-diff: Bump copyright headers 4 years ago
interfaces_tests.cpp test: Verify findCommonAncestor always initializes outputs 4 years ago
key_io_tests.cpp Test fixes 3 years ago
key_tests.cpp Litecoin: Fix various tests 3 years ago
logging_tests.cpp scripted-diff: test: Move setup_common to test library 5 years ago
main.cpp Litecoin: Branding 3 years ago
mempool_tests.cpp MWEB: Mempool 2 years ago
merkle_tests.cpp Make Hash[160] consume range-like objects 4 years ago
merkleblock_tests.cpp scripted-diff: Bump copyright headers 4 years ago
miner_tests.cpp Litecoin: Protocol and default settings 3 years ago
multisig_tests.cpp scripted-diff: TxoutType C++11 scoped enum class 4 years ago
net_tests.cpp Litecoin: Branding 3 years ago
netbase_tests.cpp Litecoin: Protocol and default settings 3 years ago
pmt_tests.cpp scripted-diff: Bump copyright headers 4 years ago
policy_fee_tests.cpp test: Add FeeFilterRounder test 4 years ago
policyestimator_tests.cpp MWEB: Mempool 2 years ago
pow_tests.cpp Litecoin: Tests 3 years ago
prevector_tests.cpp scripted-diff: Bump copyright headers 4 years ago
raii_event_tests.cpp Merge #16564: test: Always define the raii_event_tests test suite 4 years ago
random_tests.cpp Merge #18781: Add templated GetRandDuration<> 4 years ago
ref_tests.cpp Add util::Ref class as temporary alternative for c++17 std::any 4 years ago
reverselock_tests.cpp scripted-diff: Bump copyright headers 4 years ago
rpc_tests.cpp Litecoin: Fix various tests 3 years ago
sanity_tests.cpp test: fix message for ECC_InitSanityCheck test 4 years ago
scheduler_tests.cpp Merge #19090: refactor: Misc scheduler cleanups 4 years ago
script_p2sh_tests.cpp Only relay Taproot spends if next block has it active 4 years ago
script_standard_tests.cpp Replace usage of GetScriptForWitness with GetScriptForDestination 4 years ago
script_tests.cpp MWEB: Add StealthAddress to CTxDestination and add pegin and hogex script consts & logic 2 years ago
scriptnum10.h scripted-diff: Bump copyright headers 4 years ago
scriptnum_tests.cpp scripted-diff: Bump copyright headers 4 years ago
scrypt_tests.cpp Litecoin: Add scrypt N=1024 PoW 3 years ago
serialize_tests.cpp Make Hash[160] consume range-like objects 4 years ago
settings_tests.cpp refactor: Make HexStr take a span 4 years ago
sighash_tests.cpp MWEB: Block and transaction weight 2 years ago
sigopcount_tests.cpp Replace usage of GetScriptForWitness with GetScriptForDestination 4 years ago
skiplist_tests.cpp scripted-diff: test: Move setup_common to test library 5 years ago
streams_tests.cpp test: Fix outstanding -Wsign-compare errors 4 years ago
sync_tests.cpp test: Add LockStackEmpty() 4 years ago
system_tests.cpp [util] add RunCommandParseJSON 4 years ago
timedata_tests.cpp Make GetWarnings() return bilingual_str 4 years ago
torcontrol_tests.cpp scripted-diff: test: Move setup_common to test library 5 years ago
transaction_tests.cpp v0.21.2 2 years ago
txindex_tests.cpp scripted-diff: Bump copyright headers 4 years ago
txrequest_tests.cpp Report and verify expirations 4 years ago
txvalidation_tests.cpp [validation] Remove absurdfee from accepttomempool 4 years ago
txvalidationcache_tests.cpp [validation] Remove absurdfee from accepttomempool 4 years ago
uint256_tests.cpp uint256: Update constructors to c++11, make ONE static 4 years ago
util_tests.cpp Litecoin: Tests 3 years ago
util_threadnames_tests.cpp test: Set -logthreadnames in unit tests 4 years ago
validation_block_tests.cpp Litecoin: Add scrypt N=1024 PoW 3 years ago
validation_chainstate_tests.cpp Pass mempool reference to chainstate constructor 4 years ago
validation_chainstatemanager_tests.cpp Pass mempool reference to chainstate constructor 4 years ago
validation_flush_tests.cpp Pass mempool reference to chainstate constructor 4 years ago
validation_tests.cpp * txrecord refactor and introduction of txlist 2 years ago
validationinterface_tests.cpp test: Remove const to work around compiler error on xenial 4 years ago
versionbits_tests.cpp Litecoin: Add -mempoolreplacement flag and disable RBF by default 2 years ago

README.md

Unit tests

The sources in this directory are unit test cases. Boost includes a unit testing framework, and since Litecoin 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_litecoin 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_litecoin. 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_litecoin-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_litecoin has some built-in command-line arguments; for example, to run just the getarg_tests verbosely:

test_litecoin --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_litecoin --run_test=getarg_tests/doubledash

Run test_litecoin --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_litecoin executable with gdbor lldb and start debugging, just like you would with any other program:

gdb src/test/test_litecoin