Skip to content

Testing

Wesley Shillingford edited this page May 22, 2019 · 5 revisions

Testing

There are a number test binaries built when the -DNANO_TEST=ON CMake variable is set:

core_test - The majority of core functionality is tested here.
slow_test - Tests which operate on a large amount of data and so may take a while. Not currently tested by CI
rpc_test - This tests all RPC commands

To run all tests in a binary just launch it:
./core_test

To check a specific subset of tests, gtest filtering can be used (with optional wildcards):
./core_test --gtest_filter=confirmation_height.single
./rpc_test --gtest_filter=rpc.*

load_test - Launches many nodes and checks sending/receiving works with simultaneous calls. Example to use
./load-test -s 150

Sanitiziers

Nano supports 3 different CMake sanitizer options: NANO_ASAN_INT, NANO_TSAN and NANO_ASAN. They cannot be used in conjunction with each other

Thread sanitizer

Use -DNANO_TSAN=ON as an extra CMake option. When using the clang compiler this should be all that is necessary. When using gcc however the following environment variable should be set:
export TSAN=OPTIONS="suppressions=../tsan_suppressions"
tsan_suppressions should be a path to the file in the root nano directory. You must set this or see a lot of errors relating to the mdb library. The reason it is not needed with clang is that it supports -fsanitize-blacklist compiler option which we use with tsan_clang_blacklist via CMake.

Address sanitizer

Use the CMake variable -DNANO_ASAN=ON or -DNANO_ASAN_INT=ON before running a nano executable

Valgrind

Valgrind can be used to find other issues such as memory leaks. In order to run LMDB under Valgrind, the maximum map size must be smaller than half your available RAM, it is necessary to replace map_size with a much smaller value than the 128GB it is currently. e.g change the default argument in nano/node/lmdb.hpp:
mdb_env (bool &, boost::filesystem::path const &, int max_dbs = 128, size_t map_size = 128ULL * 1024 * 1024 * 1024);
to
mdb_env (bool &, boost::filesystem::path const &, int max_dbs = 128, size_t map_size = 128ULL * 1024 * 256);

Then run valgrind (there are many options available):
valgrind --leak-check=full --track-origins=yes --suppressions=../valgrind.supp ./core_test