From 609281c6c20ef1f1c9f823dc6459371dd698d957 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 17 Oct 2019 15:39:49 +0200 Subject: [PATCH 01/10] Merge #17119: doc: Fix broken bitcoin-cli examples 85016e52f6adc01735beefe5a8aefcc4f0c4aa25 [rpc] Fix broken bitcoin-cli examples (Andrew Toth) Pull request description: This fixes the `bitcoin-cli` examples for `combinerawtransaction`, `combinepsbt` and `testmempoolaccept`. They currently return `Error parsing JSON`. ACKs for top commit: laanwj: ACK 85016e52f6adc01735beefe5a8aefcc4f0c4aa25 Tree-SHA512: b561f68f7a188dc91dab1ceb98da3ac3e232143ab2b906c90f95c6b74b584599d0f3b51f067cdd3b1153931f95b3dc385e453b1a0dde86f9cb549b94560f219d --- src/rpc/rawtransaction.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 6346190ad264..ed2feb24c947 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -623,7 +623,7 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request) RPCResult::Type::STR, "", "The hex-encoded raw transaction with signature(s)" }, RPCExamples{ - HelpExampleCli("combinerawtransaction", "'[\"myhex1\", \"myhex2\", \"myhex3\"]'") + HelpExampleCli("combinerawtransaction", R"('["myhex1", "myhex2", "myhex3"]')") }, }.ToString()); @@ -878,7 +878,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request) "Sign the transaction, and get back the hex\n" + HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + "\nTest acceptance of the transaction (signed hex)\n" - + HelpExampleCli("testmempoolaccept", "[\"signedhex\"]") + + + HelpExampleCli("testmempoolaccept", R"('["signedhex"]')") + "\nAs a JSON-RPC call\n" + HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]") }, @@ -1205,7 +1205,7 @@ UniValue combinepsbt(const JSONRPCRequest& request) RPCResult::Type::STR, "", "The base64-encoded partially signed transaction" }, RPCExamples{ - HelpExampleCli("combinepsbt", "[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]") + HelpExampleCli("combinepsbt", R"('["mybase64_1", "mybase64_2", "mybase64_3"]')") }, }.ToString()); From f8ce5691092df0ce0246cddcda8f6a8b221e902c Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 10 Oct 2019 15:58:23 -0400 Subject: [PATCH 02/10] Merge #16983: doc: Add detailed info about Dash Core files 86b9f92da25f2768eb29eefd6526320135f39a2f doc: Add detailed info about Bitcoin Core files (Hennadii Stepanov) Pull request description: This PR: - provides detailed info about the Bitcoin Core files; - does not mention temporary files, e.g., `mempool.dat.new` and `peers.????` ACKs for top commit: ch4ot1c: ACK 86b9f92 laanwj: ACK 86b9f92da25f2768eb29eefd6526320135f39a2f MarcoFalke: ACK 86b9f92da25f2768eb29eefd6526320135f39a2f Tree-SHA512: 9352119b08e3f6aaab4ce3797afc6533f90852e461957acb2bc73962fd4881403fabeaa5a371bd1218309f36f9b0f90fb147b80698e2e30a016634a62a160a15 --- doc/files.md | 130 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 104 insertions(+), 26 deletions(-) diff --git a/doc/files.md b/doc/files.md index e99c1373590e..08a5342be203 100644 --- a/doc/files.md +++ b/doc/files.md @@ -1,27 +1,105 @@ +# Dash Core file system + +**Contents** + +- [Data directory location](#data-directory-location) + +- [Data directory layout](#data-directory-layout) + +- [Multi-wallet environment](#multi-wallet-environment) + +- [GUI settings](#gui-settings) + +- [Legacy subdirectories and files](#legacy-subdirectories-and-files) + +- [Notes](#notes) + +## Data directory location + +The data directory is the default location where the Dash Core files are stored. + +1. The default data directory paths for supported platforms are: + +Platform | Data directory path +---------|-------------------- +Linux | `$HOME/.dashcore/` +macOS | `$HOME/Library/Application Support/Dashcore/` +Windows | `%APPDATA%\Dashcore\` [\[1\]](#note1) + +2. The non-default data directory path can be specified by `-datadir` option. + +3. All content of the data directory, except for `dash.conf` file, is chain-specific. This means the actual data directory paths for non-mainnet cases differ: + +Chain option | Data directory path +--------------------|-------------------- +no option (mainnet) | *path_to_datadir*`/` +`-testnet` | *path_to_datadir*`/testnet3/` +`-regtest` | *path_to_datadir*`/regtest/` + +## Data directory layout + +Subdirectory | File(s) | Description +-------------------|-----------------------|------------ +`blocks/` | | Blocks directory; can be specified by `-blocksdir` option (except for `blocks/index/`) +`blocks/index/` | LevelDB database | Block index; `-blocksdir` option does not affect this path +`blocks/` | `blkNNNNN.dat`[\[2\]](#note2) | Actual Dash blocks (in network format, dumped in raw on disk, 128 MiB per file) +`blocks/` | `revNNNNN.dat`[\[2\]](#note2) | Block undo data (custom format) +`chainstate/` | LevelDB database | Blockchain state (a compact representation of all currently unspent transaction outputs and some metadata about the transactions they are from) +`indexes/txindex/` | LevelDB database | Transaction index; *optional*, used if `-txindex=1` +`wallets/` | | [Contains wallets](#multi-wallet-environment); can be specified by `-walletdir` option; if `wallets/` subdirectory does not exist, a wallet resides in the data directory +`evodb/` | |special txes and quorums database +`llmq/` | |quorum signatures database +`./` | `banlist.dat` | Stores the IPs/subnets of banned nodes +`./` | `dash.conf` | Contains [configuration settings](dash-conf.md) for `dashd` or `dash-qt`; can be specified by `-conf` option +`./` | `dashd.pid` | Stores the process ID (PID) of `dashd` or `dash-qt` while running; created at start and deleted on shutdown; can be specified by `-pid` option +`./` | `debug.log` | Contains debug information and general logging generated by `dashd` or `dash-qt`; can be specified by `-debuglogfile` option +`./` | `governance.dat` | stores data for governance objects +`./` | `mncache.dat` | stores data for masternode list +`./` | `netfulfilled.dat` | stores data about recently made network requests +`./` | `fee_estimates.dat` | Stores statistics used to estimate minimum transaction fees and priorities required for confirmation +`./` | `guisettings.ini.bak` | Backup of former [GUI settings](#gui-settings) after `-resetguisettings` option is used +`./` | `mempool.dat` | Dump of the mempool's transactions +`./` | `onion_v3_private_key` | Cached Tor hidden service private key for `-listenonion` option +`./` | `peers.dat` | Peer IP address database (custom format) +`./` | `.cookie` | Session RPC authentication cookie; if used, created at start and deleted on shutdown; can be specified by `-rpccookiefile` option +`./` | `.lock` | Data directory lock file + +## Multi-wallet environment + +Wallets are Berkeley DB (BDB) databases: + +Subdirectory | File(s) | Description +-------------|-------------------|------------ +`database/` | BDB logging files | Part of BDB environment; created at start and deleted on shutdown; a user *must keep it as safe* as personal wallet `wallet.dat` +`./` | `db.log` | BDB error file +`./` | `wallet.dat` | Personal wallet (BDB) with keys and transactions +`./` | `.walletlock` | Wallet lock file + +1. Each user-defined wallet named "wallet_name" resides in `wallets/wallet_name/` subdirectory. + +2. The default (unnamed) wallet resides in `wallets/` subdirectory; if the latter does not exist, the wallet resides in the data directory. + +3. A wallet database path can be specified by `-wallet` option. + +## GUI settings + +`dash-qt` uses [`QSettings`](https://doc.qt.io/qt-5/qsettings.html) class; this implies platform-specific [locations where application settings are stored](https://doc.qt.io/qt-5/qsettings.html#locations-where-application-settings-are-stored). + +## Legacy subdirectories and files + +These subdirectories and files are no longer used by the Dash Core: + +Path | Description | Repository notes +---------------|-------------|----------------- +`blktree/` | Blockchain index; replaced by `blocks/index/` in [0.8.0](https://github.com/dash/dash/blob/master/doc/release-notes/release-notes-0.8.0.md#improvements) | [PR #2231](https://github.com/dash/dash/pull/2231), [`8fdc94cc`](https://github.com/dash/dash/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15) +`coins/` | Unspent transaction output database; replaced by `chainstate/` in 0.8.0 | [PR #2231](https://github.com/dash/dash/pull/2231), [`8fdc94cc`](https://github.com/dash/dash/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15) +`blkindex.dat` | Blockchain index BDB database; replaced by {`chainstate/`, `blocks/index/`, `blocks/revNNNNN.dat`[\[2\]](#note2)} in 0.8.0 | [PR #1677](https://github.com/dash/dash/pull/1677) +`blk000?.dat` | Block data (custom format, 2 GiB per file); replaced by `blocks/blkNNNNN.dat`[\[2\]](#note2) in 0.8.0 | [PR #1677](https://github.com/dash/dash/pull/1677) +`addr.dat` | Peer IP address BDB database; replaced by `peers.dat` in [0.7.0](https://github.com/dash/dash/blob/master/doc/release-notes/release-notes-0.7.0.md) | [PR #1198](https://github.com/dash/dash/pull/1198), [`928d3a01`](https://github.com/dash/dash/commit/928d3a011cc66c7f907c4d053f674ea77dc611cc) + +## Notes + +1. The `/` (slash, U+002F) is used as the platform-independent path component separator in this paper. + +2. `NNNNN` matches `[0-9]{5}` regex. -* banlist.dat: stores the IPs/Subnets of banned nodes -* blocks/blk000??.dat: block data (custom, 128 MiB per file) -* blocks/rev000??.dat; block undo data (custom) -* blocks/index/*; block index (LevelDB) -* chainstate/*; block chain state database (LevelDB) -* dash.conf: contains configuration settings for dashd or dash-qt -* dashd.pid: stores the process id of dashd while running -* database/*: BDB database environment; only used for wallet; moved to wallets/ directory on new installs since 0.16.0 -* db.log: wallet database log file; moved to wallets/ directory on new installs since 0.16.0 -* debug.log: contains debug information and general logging generated by dashd or dash-qt -* evodb/*: special txes and quorums database -* fee_estimates.dat: stores statistics used to estimate minimum transaction fees and priorities required for confirmation -* governance.dat: stores data for governance objects -* indexes/txindex/*: optional transaction index database (LevelDB); since 0.17.0 -* llmq/*: quorum signatures database -* mempool.dat: dump of the mempool's transactions -* mncache.dat: stores data for masternode list -* netfulfilled.dat: stores data about recently made network requests -* peers.dat: peer IP address database (custom format) -* wallet.dat: personal wallet (BDB) with keys and transactions; moved to wallets/ directory on new installs since 0.16.0 -* wallets/database/*: BDB database environment; used for wallets since 0.16.0 -* wallets/db.log: wallet database log file; since 0.16.0 -* wallets/wallet.dat: personal wallet (BDB) with keys and transactions; since 0.16.0 -* .cookie: session RPC authentication cookie (written at start when cookie authentication is used, deleted on shutdown) -* onion_v3_private_key: cached Tor hidden service private key for `-listenonion` -* guisettings.ini.bak: backup of former GUI settings after `-resetguisettings` is used From f4ca9529b5a08732e96cfcd2188b10a82e0b455f Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 11 Oct 2019 08:49:40 -0400 Subject: [PATCH 03/10] Merge #17102: doc: Add missing indexes/blockfilter/basic to doc/files.md fa191c058f00116bb844e59e42e24ad961e19cbe doc: Add missing indexes/blockfilter/basic/ to doc/files.md (MarcoFalke) Pull request description: ACKs for top commit: hebasto: ACK fa191c058f00116bb844e59e42e24ad961e19cbe fanquake: ACK fa191c058f00116bb844e59e42e24ad961e19cbe Tree-SHA512: ea30776224e4a26bc6f60c9c65361f0b9d7b2b4f844c6d2aefd108f852dd7d813963df631a8ed20daea5acae7a23d0b405d12a162f90a6f61a3db236f5beed45 --- doc/files.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/files.md b/doc/files.md index 08a5342be203..ae05693e750f 100644 --- a/doc/files.md +++ b/doc/files.md @@ -46,6 +46,8 @@ Subdirectory | File(s) | Description `blocks/` | `revNNNNN.dat`[\[2\]](#note2) | Block undo data (custom format) `chainstate/` | LevelDB database | Blockchain state (a compact representation of all currently unspent transaction outputs and some metadata about the transactions they are from) `indexes/txindex/` | LevelDB database | Transaction index; *optional*, used if `-txindex=1` +`indexes/blockfilter/basic/db/` | LevelDB database | Blockfilter index LevelDB database for the basic filtertype; *optional*, used if `-blockfilterindex=basic` +`indexes/blockfilter/basic/` | `fltrNNNNN.dat`[\[2\]](#note2) | Blockfilter index filters for the basic filtertype; *optional*, used if `-blockfilterindex=basic` `wallets/` | | [Contains wallets](#multi-wallet-environment); can be specified by `-walletdir` option; if `wallets/` subdirectory does not exist, a wallet resides in the data directory `evodb/` | |special txes and quorums database `llmq/` | |quorum signatures database From db662cf84317cea34f49f163948604308a1dfc2e Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 14 Oct 2019 17:54:46 -0400 Subject: [PATCH 04/10] Merge #17134: doc: Add switch on enum example to developer notes c8961c7d9fed07190628cf01f9dfad971a942b99 doc: Add switch on enum example (Hennadii Stepanov) 11e3d5eb1d4a4b399b180083ec52484d53ebf724 util: Add AllowShortCaseLabelsOnASingleLine option (Hennadii Stepanov) Pull request description: This PR documents a recurring issue: - #15938 - #17105 ACKs for top commit: laanwj: Seems like good advice to me. ACK c8961c7d9fed07190628cf01f9dfad971a942b99 practicalswift: ACK c8961c7d9fed07190628cf01f9dfad971a942b99 promag: ACK c8961c7d9fed07190628cf01f9dfad971a942b99, no excuse now, thanks! Tree-SHA512: 530da5117094ed1bfaa6e447089521bd2c86b0742758dbacec4e4f934dc07b0e24f15a1448c4d58e49905e8fd3797d87bcae5669a346d33ed4c2878a04891699 --- doc/developer-notes.md | 29 ++++++++++++++++++++++++++++- src/.clang-format | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 76f04233bc14..c908916c203b 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -95,7 +95,6 @@ code. - `nullptr` is preferred over `NULL` or `(void*)0`. - `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking. - Align pointers and references to the left i.e. use `type& var` and not `type &var`. - - `enum class` is preferred over `enum` where possible. Scoped enumerations avoid two potential pitfalls/problems with traditional C++ enumerations: implicit conversions to int, and name clashes due to enumerators being exported to the surrounding scope. Block style example: ```c++ @@ -582,6 +581,34 @@ class A int. If the signed int is some negative `N`, it'll become `INT_MAX - N` which might cause unexpected consequences. +- Prefer `enum class` (scoped enumerations) over `enum` (traditional enumerations) where possible. + + - *Rationale*: Scoped enumerations avoid two potential pitfalls/problems with traditional C++ enumerations: implicit conversions to `int`, and name clashes due to enumerators being exported to the surrounding scope. + +- `switch` statement on an enumeration example: + +```cpp +enum class Tabs { + INFO, + CONSOLE, + GRAPH, + PEERS +}; + +int GetInt(Tabs tab) +{ + switch (tab) { + case Tabs::INFO: return 0; + case Tabs::CONSOLE: return 1; + case Tabs::GRAPH: return 2; + case Tabs::PEERS: return 3; + } // no default case, so the compiler can warn about missing cases + assert(false); +} +``` + +*Rationale*: The comment documents skipping `default:` label, and it complies with `clang-format` rules. The assertion prevents firing of `-Wreturn-type` warning on some compilers. + Strings and formatting ------------------------ diff --git a/src/.clang-format b/src/.clang-format index bedf672b61c9..7e649de43fb4 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -5,6 +5,7 @@ AlignEscapedNewlinesLeft: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false From 6270a09847f2c2783c74ab0b1f1b8ea221157417 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 16 Jan 2020 15:57:24 -0500 Subject: [PATCH 05/10] Merge #17691: doc: Add missed copyright headers fac86ac7b3ceac2f884412c7a9f4bd5bab5e3916 scripted-diff: Add missed copyright headers (Hennadii Stepanov) 6fde9d5e47fc9a1042b3fb68031eab5bf55e508d script: Update EXLUDE list in copyright_header.py (Hennadii Stepanov) 1998152f15fd2b0e83f5068c375a34feaf73db8c script: Add empty line after C++ copyright (Hennadii Stepanov) 071f2fc204f542c5a287ca8835115a2ee0bf2f50 script: Add ability to insert copyright to *.sh (Hennadii Stepanov) Pull request description: This PR improves `contrib/devtools/copyright_header.py` script and adds copyright headers to the files in `src` and `test` directories with two exceptions: - [`src/reverse_iterator.h`](https://github.com/bitcoin/bitcoin/blob/master/src/reverse_iterator.h) (added to exceptions) - [`src/test/fuzz/FuzzedDataProvider.h`](https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/FuzzedDataProvider.h) (added to exceptions) On master 5622d8f3156a293e61d0964c33d4b21d8c9fd5e0: ``` $ ./contrib/devtools/copyright_header.py report . | grep zero 25 with zero copyrights ``` With this PR: ``` $ ./contrib/devtools/copyright_header.py report . | grep zero 2 with zero copyrights ``` ~I am uncertain about our copyright policy with `build_msvc` and `contrib` directories content, so they are out of scope of this PR.~ ACKs for top commit: MarcoFalke: ACK fac86ac7b3ceac2f884412c7a9f4bd5bab5e3916 Tree-SHA512: d7832c4a7a1a3b7806119775b40ec35d7982f49ff0e6199b8cee4c0e0a36e68d51728b6ee9924b1c161df4bc6105bd93391b79d42914357fa522f499cb113fa8 --- contrib/devtools/circular-dependencies.py | 3 +++ contrib/devtools/copyright_header.py | 21 +++++++++++++-------- contrib/devtools/gen-manpages.sh | 3 +++ contrib/filter-lcov.py | 3 +++ contrib/gitian-build.py | 3 +++ src/crypto/sha256_avx2.cpp | 4 ++++ src/crypto/sha256_sse41.cpp | 4 ++++ src/fs.cpp | 4 ++++ src/qt/test/addressbooktests.cpp | 4 ++++ src/qt/test/addressbooktests.h | 4 ++++ src/qt/test/util.cpp | 4 ++++ src/qt/test/util.h | 4 ++++ src/qt/test/wallettests.cpp | 4 ++++ src/qt/test/wallettests.h | 4 ++++ src/test/blockchain_tests.cpp | 4 ++++ test/functional/combine_logs.py | 3 +++ test/lint/lint-locale-dependence.sh | 3 +++ test/lint/lint-shebang.sh | 4 ++++ 18 files changed, 75 insertions(+), 8 deletions(-) diff --git a/contrib/devtools/circular-dependencies.py b/contrib/devtools/circular-dependencies.py index 5b73a1cd7472..98a1a24b28fb 100755 --- a/contrib/devtools/circular-dependencies.py +++ b/contrib/devtools/circular-dependencies.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. import sys import re diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index 3290a8e55b24..e9eea42b962b 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -20,6 +20,8 @@ 'src/qt/bitcoinstrings.cpp', 'src/chainparamsseeds.h', # other external copyrights: + 'src/reverse_iterator.h', + 'src/test/fuzz/FuzzedDataProvider.h', 'src/tinyformat.h', 'src/bench/nanobench.h', 'test/functional/test_framework/bignum.py', @@ -459,14 +461,14 @@ def get_header_lines(header, start_year, end_year): def get_cpp_header_lines_to_insert(start_year, end_year): return reversed(get_header_lines(CPP_HEADER, start_year, end_year)) -PYTHON_HEADER = ''' +SCRIPT_HEADER = ''' # Copyright (c) %s The Dash Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' -def get_python_header_lines_to_insert(start_year, end_year): - return reversed(get_header_lines(PYTHON_HEADER, start_year, end_year)) +def get_script_header_lines_to_insert(start_year, end_year): + return reversed(get_header_lines(SCRIPT_HEADER, start_year, end_year)) ################################################################################ # query git for year of last change @@ -495,17 +497,18 @@ def file_has_hashbang(file_lines): return False return file_lines[0][:2] == '#!' -def insert_python_header(filename, file_lines, start_year, end_year): +def insert_script_header(filename, file_lines, start_year, end_year): if file_has_hashbang(file_lines): insert_idx = 1 else: insert_idx = 0 - header_lines = get_python_header_lines_to_insert(start_year, end_year) + header_lines = get_script_header_lines_to_insert(start_year, end_year) for line in header_lines: file_lines.insert(insert_idx, line) write_file_lines(filename, file_lines) def insert_cpp_header(filename, file_lines, start_year, end_year): + file_lines.insert(0, '\n') header_lines = get_cpp_header_lines_to_insert(start_year, end_year) for line in header_lines: file_lines.insert(0, line) @@ -517,8 +520,8 @@ def exec_insert_header(filename, style): sys.exit('*** %s already has a copyright by The Dash Core developers' % (filename)) start_year, end_year = get_git_change_year_range(filename) - if style == 'python': - insert_python_header(filename, file_lines, start_year, end_year) + if style in ['python', 'shell']: + insert_script_header(filename, file_lines, start_year, end_year) else: insert_cpp_header(filename, file_lines, start_year, end_year) @@ -559,11 +562,13 @@ def insert_cmd(argv): if not os.path.isfile(filename): sys.exit("*** bad filename: %s" % filename) _, extension = os.path.splitext(filename) - if extension not in ['.h', '.cpp', '.cc', '.c', '.py']: + if extension not in ['.h', '.cpp', '.cc', '.c', '.py', '.sh']: sys.exit("*** cannot insert for file extension %s" % extension) if extension == '.py': style = 'python' + elif extension == '.sh': + style = 'shell' else: style = 'cpp' exec_insert_header(filename, style) diff --git a/contrib/devtools/gen-manpages.sh b/contrib/devtools/gen-manpages.sh index 0f6afd6153b2..c5753e485586 100755 --- a/contrib/devtools/gen-manpages.sh +++ b/contrib/devtools/gen-manpages.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# Copyright (c) 2016-2019 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} diff --git a/contrib/filter-lcov.py b/contrib/filter-lcov.py index df1db76e924e..75034616f745 100755 --- a/contrib/filter-lcov.py +++ b/contrib/filter-lcov.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# Copyright (c) 2017-2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. import argparse diff --git a/contrib/gitian-build.py b/contrib/gitian-build.py index 4fbd7416bcd1..9b599e52fb2b 100755 --- a/contrib/gitian-build.py +++ b/contrib/gitian-build.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# Copyright (c) 2018-2019 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. import argparse import os diff --git a/src/crypto/sha256_avx2.cpp b/src/crypto/sha256_avx2.cpp index 90a72516a442..624bdb42e474 100644 --- a/src/crypto/sha256_avx2.cpp +++ b/src/crypto/sha256_avx2.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2017-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifdef ENABLE_AVX2 #include diff --git a/src/crypto/sha256_sse41.cpp b/src/crypto/sha256_sse41.cpp index fc79f46f7f29..4eaf7d7b188c 100644 --- a/src/crypto/sha256_sse41.cpp +++ b/src/crypto/sha256_sse41.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2018-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifdef ENABLE_SSE41 #include diff --git a/src/fs.cpp b/src/fs.cpp index 9f19dfd52f8e..5a75c6317e79 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2017-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #ifndef WIN32 diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index a4c513f9bf77..1d591bf196bb 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2017-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include #include diff --git a/src/qt/test/addressbooktests.h b/src/qt/test/addressbooktests.h index beeb9e76a980..aa1b2f20b06c 100644 --- a/src/qt/test/addressbooktests.h +++ b/src/qt/test/addressbooktests.h @@ -1,3 +1,7 @@ +// Copyright (c) 2018-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H #define BITCOIN_QT_TEST_ADDRESSBOOKTESTS_H diff --git a/src/qt/test/util.cpp b/src/qt/test/util.cpp index ae2fb93bf796..e09f0ad77dc7 100644 --- a/src/qt/test/util.cpp +++ b/src/qt/test/util.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include #include diff --git a/src/qt/test/util.h b/src/qt/test/util.h index 377f07dcba9c..763847606ae7 100644 --- a/src/qt/test/util.h +++ b/src/qt/test/util.h @@ -1,3 +1,7 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef BITCOIN_QT_TEST_UTIL_H #define BITCOIN_QT_TEST_UTIL_H diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 24b230fb10a9..57469d7843c2 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2015-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include diff --git a/src/qt/test/wallettests.h b/src/qt/test/wallettests.h index 342f7916c30b..388eb9500e37 100644 --- a/src/qt/test/wallettests.h +++ b/src/qt/test/wallettests.h @@ -1,3 +1,7 @@ +// Copyright (c) 2017-2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef BITCOIN_QT_TEST_WALLETTESTS_H #define BITCOIN_QT_TEST_WALLETTESTS_H diff --git a/src/test/blockchain_tests.cpp b/src/test/blockchain_tests.cpp index 29935c09f89b..65c073a13dba 100644 --- a/src/test/blockchain_tests.cpp +++ b/src/test/blockchain_tests.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2017-2019 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include diff --git a/test/functional/combine_logs.py b/test/functional/combine_logs.py index 7268a5216b3e..22a1fbe4aa6e 100755 --- a/test/functional/combine_logs.py +++ b/test/functional/combine_logs.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +# Copyright (c) 2017-2019 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. """Combine logs from multiple bitcoin nodes as well as the test_framework log. This streams the combined log output to stdout. Use combine_logs.py > outputfile diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 1f52f13ed6d4..accf459c89da 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +# Copyright (c) 2018-2019 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C diff --git a/test/lint/lint-shebang.sh b/test/lint/lint-shebang.sh index fda22592d30f..a666fdfecfc4 100755 --- a/test/lint/lint-shebang.sh +++ b/test/lint/lint-shebang.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + # Assert expected shebang lines export LC_ALL=C From 92798c6fb5eb5fd248de37b1623a1febfa4f6e3d Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 8 Jan 2020 14:43:55 +0100 Subject: [PATCH 06/10] Merge #16975: test: Show debug log on unit test failure fa37e0a68bea65979f9f8f2e5258fe608acf2bdf test: Show debug log on unit test failure (MarcoFalke) Pull request description: Often, it is hard to debug unit test failures without the debug log. Especially when the failure happens remotely (e.g. on a ci system). Fix that by printing the log on failure. ACKs for top commit: jamesob: ACK fa37e0a68bea65979f9f8f2e5258fe608acf2bdf ([`jamesob/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u`](https://github.com/jamesob/bitcoin/tree/ackr/16975.1.MarcoFalke.test_show_debug_log_on_u)) Tree-SHA512: 2ca4150c4ae3d4ad47e03b5e5e70da2baffec928ddef1fdf53a3ebc061f14aee249205387cb1b12ef6d4eb55711ef0080c0b41d9d18000b5da124ca80299793b --- src/bench/bench.cpp | 1 + src/qt/test/test_main.cpp | 2 ++ src/test/fuzz/fuzz.cpp | 4 ++++ src/test/main.cpp | 15 +++++++++++++++ src/test/util/setup_common.cpp | 1 + src/test/util/setup_common.h | 3 +++ test/sanitizer_suppressions/tsan | 8 ++++++++ 7 files changed, 34 insertions(+) diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index f26d6fc7b853..3e251ed15d81 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -13,6 +13,7 @@ #include #include +const std::function G_TEST_LOG_FUN{}; namespace { void GenerateTemplateResults(const std::vector& benchmarkResults, const std::string& filename, const char* tpl) diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 05ba03408481..a2f55a566047 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -46,6 +46,8 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); #endif #endif +const std::function G_TEST_LOG_FUN{}; + // This is all you need to run all the tests int main(int argc, char *argv[]) { diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index 5bf279f4c5f5..3984f68116ba 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -4,10 +4,14 @@ #include +#include + #include #include #include +const std::function G_TEST_LOG_FUN{}; + static bool read_stdin(std::vector& data) { uint8_t buffer[1024]; diff --git a/src/test/main.cpp b/src/test/main.cpp index 1862ee48df96..5e4969ab9343 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -2,6 +2,21 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +/** + * See https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/link_references/link_boost_test_module_macro.html + */ #define BOOST_TEST_MODULE Dash Core Test Suite #include + +#include + +/** Redirect debug log to boost log */ +const std::function G_TEST_LOG_FUN = [](const std::string& s) { + if (s.back() == '\n') { + // boost will insert the new line + BOOST_TEST_MESSAGE(s.substr(0, s.size() - 1)); + } else { + BOOST_TEST_MESSAGE(s); + } +}; diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index ef83718af1fc..219dab919b86 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -77,6 +77,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName) SelectParams(chainName); SeedInsecureRand(); gArgs.ForceSetArg("-printtoconsole", "0"); + if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN); InitLogging(); LogInstance().StartLogging(); SHA256AutoDetect(); diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 378e2a00f6f1..40de4fe87ab6 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -19,6 +19,9 @@ #include +/** This is connected to the logger. Can be used to redirect logs to any other log */ +extern const std::function G_TEST_LOG_FUN; + // Enable BOOST_CHECK_EQUAL for enum class types template std::ostream& operator<<(typename std::enable_if::value, std::ostream>::type& stream, const T& e) diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan index 7e8be7c705f8..073d1d451048 100644 --- a/test/sanitizer_suppressions/tsan +++ b/test/sanitizer_suppressions/tsan @@ -13,6 +13,14 @@ deadlock:CChainState::ConnectTip # Intentional deadlock in tests deadlock:sync_tests::potential_deadlock_detected +# Race due to unprotected calls to thread-unsafe BOOST_TEST_MESSAGE from different threads: +# * G_TEST_LOG_FUN in the index thread +# * boost test case invoker (entering a test case) in the main thread +# TODO: get rid of BOOST_ macros, see also https://github.com/bitcoin/bitcoin/issues/8670 +race:blockfilter_index_initial_sync_invoker +race:txindex_initial_sync_invoker +race:validation_block_tests::TestSubscriber + # Wildcard for all gui tests, should be replaced with non-wildcard suppressions race:src/qt/test/* deadlock:src/qt/test/* From 639386a7a1efcdb63b4a4276314a5e77b0f8b124 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 31 Mar 2020 15:39:08 -0400 Subject: [PATCH 07/10] Merge #18472: test: Remove unsafe BOOST_TEST_MESSAGE fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 test: Remove unsafe BOOST_TEST_MESSAGE (MarcoFalke) Pull request description: Fixes #17987 Can be tested with ``` ./src/test/test_bitcoin -l test_suite -- DEBUG_LOG_OUT ACKs for top commit: fjahr: tested ACK fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 mzumsande: Tested ACK fa3cc0bfc4c4fc13a384fc291403c9fd41082f18 Tree-SHA512: f63b110d77882cd7c0d7574ff6c9c948db8febb3400ecdac45164746b587b0fa223463041801271b3959267ddc1d9a4a67ba76939e242e7dd2f92a2834a400a0 --- src/Makefile.test.include | 2 +- src/test/main.cpp | 18 +++++++++++------- test/sanitizer_suppressions/tsan | 8 -------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index a08053982eea..392c022c71d9 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -685,7 +685,7 @@ endif %.cpp.test: %.cpp @echo Running tests: `cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1` from $< - $(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" > $<.log 2>&1 || (cat $<.log && false) + $(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" -- DEBUG_LOG_OUT > $<.log 2>&1 || (cat $<.log && false) test/data/%.json.h: test/data/%.json @$(MKDIR_P) $(@D) diff --git a/src/test/main.cpp b/src/test/main.cpp index 5e4969ab9343..3efeb827eab1 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -11,12 +11,16 @@ #include -/** Redirect debug log to boost log */ +#include + +/** Redirect debug log to unit_test.log files */ const std::function G_TEST_LOG_FUN = [](const std::string& s) { - if (s.back() == '\n') { - // boost will insert the new line - BOOST_TEST_MESSAGE(s.substr(0, s.size() - 1)); - } else { - BOOST_TEST_MESSAGE(s); - } + static const bool should_log{std::any_of( + &boost::unit_test::framework::master_test_suite().argv[1], + &boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc], + [](const char* arg) { + return std::string{"DEBUG_LOG_OUT"} == arg; + })}; + if (!should_log) return; + std::cout << s; }; diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan index 073d1d451048..7e8be7c705f8 100644 --- a/test/sanitizer_suppressions/tsan +++ b/test/sanitizer_suppressions/tsan @@ -13,14 +13,6 @@ deadlock:CChainState::ConnectTip # Intentional deadlock in tests deadlock:sync_tests::potential_deadlock_detected -# Race due to unprotected calls to thread-unsafe BOOST_TEST_MESSAGE from different threads: -# * G_TEST_LOG_FUN in the index thread -# * boost test case invoker (entering a test case) in the main thread -# TODO: get rid of BOOST_ macros, see also https://github.com/bitcoin/bitcoin/issues/8670 -race:blockfilter_index_initial_sync_invoker -race:txindex_initial_sync_invoker -race:validation_block_tests::TestSubscriber - # Wildcard for all gui tests, should be replaced with non-wildcard suppressions race:src/qt/test/* deadlock:src/qt/test/* From cacc5c43ee235c969935966153ee4f18726360f8 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 1 Apr 2020 05:06:44 +0200 Subject: [PATCH 08/10] Merge #18486: doc: Explain new test logging 7777703958937ec0ae609b1ee882f1bf2d113d10 doc: Explain new test logging (MarcoFalke) Pull request description: Explain logging added in #18472 and #16975 ACKs for top commit: jonatack: ACK 7777703 Tree-SHA512: 3a0aa7bab32a6753d8894d29cf82604b044b23e512102dd275b717eefda3c2212dbf43ea7e9155267350dd9f3bc5badba2eb660152db3efeab30a04f52126c95 --- src/test/README.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/test/README.md b/src/test/README.md index 05e7a8178c60..e46152b7e879 100644 --- a/src/test/README.md +++ b/src/test/README.md @@ -17,26 +17,31 @@ and tests weren't explicitly disabled. After configuring, they can be run with `make check`. -To run the dashd tests manually, launch `src/test/test_dash`. To recompile +To run the unit tests manually, launch `src/test/test_dash`. 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 dashd tests. +to run the unit tests. -To add more dashd tests, add `BOOST_AUTO_TEST_CASE` functions to the existing +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 dash-qt tests manually, launch `src/qt/test/test_dash-qt` +To run the GUI unit tests manually, launch `src/qt/test/test_dash-qt` -To add more dash-qt tests, add them to the `src/qt/test/` directory and +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_dash has some built-in command-line arguments; for -example, to run just the getarg_tests verbosely: +`test_dash` has some built-in command-line arguments; for +example, to run just the `getarg_tests` verbosely: - test_dash --log_level=all --run_test=getarg_tests + test_dash --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: @@ -56,11 +61,15 @@ 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](#running-individual-tests). + 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_dash executable with `gdb`or `lldb` and -start debugging, just like you would with dashd: +For debugging you can launch the `test_dash` executable with `gdb`or `lldb` and +start debugging, just like you would with any other program: ```bash gdb src/test/test_dash From 77f106ebf588dc0c8e9a6d4ed51649465faace08 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 10 Dec 2019 13:30:05 -0500 Subject: [PATCH 09/10] Merge #17633: tests: Add option --valgrind to run the functional tests under Valgrind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5db506ba5943868cc2c845f717508739b7f05714 tests: Add option --valgrind to run nodes under valgrind in the functional tests (practicalswift) Pull request description: What is better than fixing bugs? Fixing entire bug classes of course! :) Add option `--valgrind` to run the functional tests under Valgrind. Regular functional testing under Valgrind would have caught many of the uninitialized reads we've seen historically. Let's kill this bug class once and for all: let's never use an uninitialized value ever again. Or at least not one that would be triggered by running the functional tests! :) My hope is that this addition will make it super-easy to run the functional tests under Valgrind and thus increase the probability of people making use of it :) Hopefully `test/functional/test_runner.py --valgrind` will become a natural part of the pre-release QA process. **Usage:** ``` $ test/functional/test_runner.py --help … --valgrind run nodes under the valgrind memory error detector: expect at least a ~10x slowdown, valgrind 3.14 or later required ``` **Live demo:** First, let's re-introduce a memory bug by reverting the recent P2P uninitialized read bug fix from PR #17624 ("net: Fix an uninitialized read in ProcessMessage(…, "tx", …) when receiving a transaction we already have"). ``` $ git diff diff --git a/src/consensus/validation.h b/src/consensus/validation.h index 3401eb64c..940adea33 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -114,7 +114,7 @@ inline ValidationState::~ValidationState() {}; class TxValidationState : public ValidationState { private: - TxValidationResult m_result = TxValidationResult::TX_RESULT_UNSET; + TxValidationResult m_result; public: bool Invalid(TxValidationResult result, const std::string &reject_reason="", ``` Second, let's test as normal without Valgrind: ``` $ test/functional/p2p_segwit.py -l INFO 2019-11-28T09:30:42.810000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test__fc8q3qo … 2019-11-28T09:31:57.187000Z TestFramework (INFO): Subtest: test_non_standard_witness_blinding (Segwit active = True) … 2019-11-28T09:32:08.265000Z TestFramework (INFO): Tests successful ``` Third, let's test with `--valgrind` and see if the test fail (as we expect) when the unitialized value is used: ``` $ test/functional/p2p_segwit.py -l INFO --valgrind 2019-11-28T09:32:33.018000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_gtjecx2l … 2019-11-28T09:40:36.702000Z TestFramework (INFO): Subtest: test_non_standard_witness_blinding (Segwit active = True) 2019-11-28T09:40:37.813000Z TestFramework (ERROR): Assertion failed ConnectionRefusedError: [Errno 111] Connection refused ``` ACKs for top commit: MarcoFalke: ACK 5db506ba5943868cc2c845f717508739b7f05714 jonatack: ACK 5db506ba5943868cc2c845f717508739b7f05714 Tree-SHA512: 2eaecacf4da166febad88b2a8ee6d7ac2bcd38d4c1892ca39516b6343e8f8c8814edf5eaf14c90f11a069a0389d24f0713076112ac284de987e72fc5f6cc3795 --- test/functional/test_framework/test_framework.py | 3 +++ test/functional/test_framework/test_node.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index d3d80dfd10d3..5465415aea13 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -156,6 +156,8 @@ def main(self): help="Scale the test timeouts by multiplying them with the here provided value (default: %(default)s)") parser.add_argument("--perf", dest="perf", default=False, action="store_true", help="profile running nodes with perf for the duration of the test") + parser.add_argument("--valgrind", dest="valgrind", default=False, action="store_true", + help="run nodes under the valgrind memory error detector: expect at least a ~10x slowdown, valgrind 3.14 or later required") parser.add_argument("--randomseed", type=int, help="set a random seed for deterministically reproducing a previous test run") self.add_options(parser) @@ -405,6 +407,7 @@ def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None): extra_args=extra_args[i], use_cli=self.options.usecli, start_perf=self.options.perf, + use_valgrind=self.options.valgrind, )) def start_node(self, i, *args, **kwargs): diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 098b055f5af3..e3c9b566e5a1 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -60,7 +60,7 @@ class TestNode(): To make things easier for the test writer, any unrecognised messages will be dispatched to the RPC connection.""" - def __init__(self, i, datadir, extra_args_from_options, *, chain, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False): + def __init__(self, i, datadir, extra_args_from_options, *, chain, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False): """ Kwargs: start_perf (bool): If True, begin profiling the node with `perf` as soon as @@ -101,6 +101,15 @@ def __init__(self, i, datadir, extra_args_from_options, *, chain, rpchost, timew "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i ] + if use_valgrind: + default_suppressions_file = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "..", "..", "..", "contrib", "valgrind.supp") + suppressions_file = os.getenv("VALGRIND_SUPPRESSIONS_FILE", + default_suppressions_file) + self.args = ["valgrind", "--suppressions={}".format(suppressions_file), + "--gen-suppressions=all", "--exit-on-first-error=yes", + "--error-exitcode=1", "--quiet"] + self.args self.cli = TestNodeCLI(bitcoin_cli, self.datadir) self.use_cli = use_cli From f80a99c3b0c430468c08b9b2069e2a00de4c87a7 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 11 Mar 2020 10:21:02 -0400 Subject: [PATCH 10/10] Merge #17833: doc: Added running functional tests in valgrind 155a11f897c7dfdc891587cc7ddd7c153cbc2a8f doc: Added running functional tests in valgrind (Elichai Turkel) Pull request description: Technically the notes only show an "example" of how to run valgrind with the suppression file, but now that https://github.com/bitcoin/bitcoin/pull/17633 is merged then maybe this can encourage more people to run also the functional tests in valgrind Top commit has no ACKs. Tree-SHA512: b8417249b720d0ed5e10b732648f2e07e8889bfc7aa7e94192d1c049b4b7837971678d30c535f273c227848f1290cf11e14369fd6c1924b734f2e47e2af41401 --- doc/developer-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index c908916c203b..34933ec09d23 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -256,6 +256,7 @@ $ valgrind --suppressions=contrib/valgrind.supp src/test/test_dash $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \ --show-leak-kinds=all src/test/test_dash --log_level=test_suite $ valgrind -v --leak-check=full src/dashd -printtoconsole +$ ./test/functional/test_runner.py --valgrind ``` ### Compiling for test coverage