Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251argument.253`test_framework.log` and bitcoind `debug.log`s can be combined into a single254aggregate log by running the `combine_logs.py` script. The output can be plain255text, colorized text or html. For example:257```258build/test/functional/combine_logs.py -c <test data directory> | less -r259```261will pipe the colorized logs from the test into less.263Use `--tracerpc` to trace out all the RPC calls and responses to the console. For264some tests (eg any that use `submitblock` to submit a full block over RPC),265this can result in a lot of screen output.267By default, the test data directory will be deleted after a successful run.268Use `--nocleanup` to leave the test data directory intact. The test data269directory is never deleted after a failed test.271##### Attaching a debugger273A python debugger can be attached to tests at any point. Just add the line:275```py276import pdb; pdb.set_trace()277```279anywhere in the test. You will then be able to inspect variables, as well as280call methods that interact with the bitcoind nodes-under-test.282If further introspection of the bitcoind instances themselves becomes283necessary, this can be accomplished by first setting a pdb breakpoint284at an appropriate location, running the test to that point, then using285`gdb` (or `lldb` on macOS) to attach to the process and debug.287For instance, to attach to `self.node[1]` during a run you can get288the pid of the node within `pdb`.290```291(pdb) self.node[1].process.pid292```294Alternatively, you can find the pid by inspecting the temp folder for the specific test295you are running. The path to that folder is printed at the beginning of every296test run:298```bash2992017-06-27 14:13:56.686000 TestFramework (INFO): Initializing test directory /tmp/user/1000/testo9vsdjo3300```302Use the path to find the pid file in the temp folder:304```bash305cat /tmp/user/1000/testo9vsdjo3/node1/regtest/bitcoind.pid306```308Then you can use the pid to start `gdb`:310```bash311gdb /home/example/bitcoind <pid>312```314Note: gdb attach step may require ptrace_scope to be modified, or `sudo` preceding the `gdb`.315See this link for considerations: https://www.kernel.org/doc/Documentation/security/Yama.txt317Often while debugging RPC calls in functional tests, the test might time out before the318process can return a response. Use `--timeout-factor 0` to disable all RPC timeouts for that particular319functional test. Ex: `build/test/functional/wallet_hd.py --timeout-factor 0`.321### Lint tests323See the README in [test/lint](/test/lint).325# Writing functional tests327You are encouraged to write functional tests for new or existing features.328Further information about the functional test framework and individual329tests is found in [test/functional](/test/functional).
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.