aboutsummaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2019-11-01Merge #17254: test: fix script_p2sh_tests OP_PUSHBACK2/4 missingMarcoFalke
5710dadf9b282524fddf42c682351cd8022ed7bf test: fix script_p2sh_tests OP_PUSHBACK2/4 missing (kodslav) Pull request description: Cleans up #15140 which fixes commit 6b25f29a91 where opcodes were lost in translation. ACKs for top commit: laanwj: code review ACK 5710dadf9b282524fddf42c682351cd8022ed7bf Tree-SHA512: 3f7fbcaf0dd199626d9ec9fdf3c5b5c5c2a91c4cfe81fae5b1d5662a48e52cf4bd27c94f8f42ebdfe7a076c5d600ada5661a6902b03eb5dc3dc953f4524345ac
2019-11-01test: Do not instantiate CAddrDB for static callHennadii Stepanov
2019-10-31Merge #17274: tests: Fix fuzzers eval_script and script_flags by re-adding ↵MarcoFalke
ECCVerifyHandle dependency 9cae3d5e94f4481e0d251c924314e57187a07a60 tests: Add fuzzer initialization (hold ECCVerifyHandle) (practicalswift) Pull request description: The fuzzers `eval_script` and `script_flags` require holding `ECCVerifyHandle`. This is a follow-up to #17235 which accidentally broke those two fuzzers. Sorry about the temporary breakage my fuzzing friends: it took a while to fuzz before reaching these code paths. That's why this wasn't immediately caught. Sorry. Top commit has no ACKs. Tree-SHA512: 67ebb155ba90894c07eac630e33f2f985c97bdf96dc751f312633414abeccdca20315d7d8f2ec4ee3ac810b666a1e44afb4ea8bc28165151cd51b623f816cac2
2019-10-30Merge #15921: validation: Tidy up ValidationState interfaceWladimir J. van der Laan
3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf [validation] Remove fMissingInputs from AcceptToMemoryPool() (John Newbery) c428622a5bb1e37b2e6ab2c52791ac05d9271238 [validation] Remove unused first_invalid parameter from ProcessNewBlockHeaders() (John Newbery) 7204c6434b944f6ad51b3c895837729d3aa56eea [validation] Remove useless ret parameter from Invalid() (John Newbery) 1a37de4b3174d19a6d8691ae07e92b32fdfaef11 [validation] Remove error() calls from Invalid() calls (John Newbery) 067981e49246822421a7bcc720491427e1dba8a3 [validation] Tidy Up ValidationResult class (John Newbery) a27a2957ed9afbe5a96caa5f0f4cbec730d27460 [validation] Add CValidationState subclasses (John Newbery) Pull request description: Carries out some remaining tidy-ups remaining after PR 15141: - split ValidationState into TxValidationState and BlockValidationState (commit from ajtowns) - various minor code style tidy-ups to the ValidationState class - remove the useless `ret` parameter from `ValidationState::Invalid()` - remove the now unused `first_invalid` parameter from `ProcessNewBlockHeaders()` - remove the `fMissingInputs` parameter from `AcceptToMemoryPool()`, and deal with missing inputs the same way as other errors by using the `TxValidationState` object. Tip for reviewers (thanks ryanofsky!): The first commit ("[validation] Add CValidationState subclasses" ) is huge and can be easier to start reviewing if you revert the rote, mechanical changes: Substitute the commit hash of commit "[validation] Add CValidationState subclasses" for <CommitHash> in the commands below. ```sh git checkout <CommitHash> git grep -l ValidationState | xargs sed -i 's/BlockValidationState\|TxValidationState/CValidationState/g' git grep -l ValidationResult | xargs sed -i 's/BlockValidationResult\|TxValidationResult/ValidationInvalidReason/g' git grep -l MaybePunish | xargs sed -i 's/MaybePunishNode\(ForBlock\|ForTx\)/MaybePunishNode/g' git diff HEAD^ ``` After that it's possible to easily see the mechanical changes with: ```sh git log -p -n1 -U0 --word-diff-regex=. <CommitHash> ``` ACKs for top commit: laanwj: ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf amitiuttarwar: code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf. Also built & ran tests locally. fjahr: Code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf . Only nit style change and pure virtual destructor added since my last review. ryanofsky: Code review ACK 3004d5a12d09d94bfc4dee2a8e8f2291996a4aaf. Just whitespace change and pure virtual destructor added since last review. Tree-SHA512: 511de1fb380a18bec1944ea82b513b6192df632ee08bb16344a2df3c40811a88f3872f04df24bc93a41643c96c48f376a04551840fd804a961490d6c702c3d36
2019-10-30Merge #17291: tests: Add fuzzing harness for ISO-8601 related functionsMarcoFalke
595cc9bcafb16709c0dd4a36d5921feb009ce430 docs: Add undefined to --with-sanitizers=fuzzer,address (practicalswift) d5dbb4898c437d3d2a5798d79c3986ba9e0b72f9 tests: Add fuzzing harness for ISO-8601 related functions (practicalswift) Pull request description: Add fuzzing harness for ISO-8601 related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/parse_iso8601 … ``` Top commit has no ACKs. Tree-SHA512: 8d4ad9e4eef546e97ea330cf518fdd7241c6f016d6c45c011369d5cdd832bbbc3564d1a990c953ffb33b0c05e58f5533e7b6fd77062f8484df36da1513567915
2019-10-30tests: Add fuzzing harness for ISO-8601 related functionspracticalswift
2019-10-30Merge #16839: Replace Connman and BanMan globals with NodeContext localWladimir J. van der Laan
362ded410b8cb1104b7ef31ff8488fec4824a7d5 Avoid using g_rpc_node global in wallet code (Russell Yanofsky) 8922d7f6b751a3e6b3b9f6fb7961c442877fb65a scripted-diff: Remove g_connman, g_banman globals (Russell Yanofsky) e6f4f895d5e42feaf7bfa5f41e80292aaa73cd7d Pass NodeContext, ConnMan, BanMan references more places (Russell Yanofsky) 4d5448c76b71c9d91399c31b043237091be2e5e7 MOVEONLY: Move NodeContext struct to node/context.h (Russell Yanofsky) 301bd41a2e6765b185bd55f4c541f9e27aeea29d scripted-diff: Rename InitInterfaces to NodeContext (Russell Yanofsky) Pull request description: This change is mainly a naming / organization change intended to simplify #10102. It: - Renames struct InitInterfaces to struct NodeContext and moves it from src/init.h to src/node/context.h. This is a cosmetic change intended to make the point of the struct more obvious. - Gets rid of BanMan and ConnMan globals making them NodeContext members instead. Getting rid of these globals has been talked about in past as a way to implement testing and simulations. Making them NodeContext members is a way of keeping them accessible without the globals. - Splits g_rpc_interfaces global into g_rpc_node and g_rpc_chain globals. This better separates node and wallet rpc methods. Node RPC methods should have access NodeContext, while wallet RPC methods should only have indirect access to node functionality via interfaces::Chain. - Adds NodeContext& references to interfaces::Chain class and the interfaces::MakeChain() function. This is needed to access ConnMan and BanMan instances without the globals. - Gets rid of redundant Node and Chain instances in Qt tests. This is needed due to the previous MakeChain change, and also makes test setup a little more straightforward. More cleanup could be done in the future, but it will require deduplication of bitcoind, bitcoin-qt, and TestingSetup init code. ACKs for top commit: laanwj: ACK 362ded410b8cb1104b7ef31ff8488fec4824a7d5 Tree-SHA512: 9ae6ff1e33423291d1e52056bac95e0874538390892a6e83c4c115b3c73155a8827c0191b46eb3d14e3b3f6c23ccb08095490880fbc3188026319c71739f7db2
2019-10-29Merge #17299: test: add reason checks for non-standard txs in test_IsStandardMarcoFalke
c1c6c410a66996b2d60d5172189b5a5ec8100842 test: add reason checks for non-standard txs in test_IsStandard (Sebastian Falbesoner) Pull request description: While taking a look at #17272 I noticed that for some reason the unit test `test_IsStandard` (which was not adapted to the policy change in the referenced PR commits) didn't fail as expected: https://github.com/bitcoin/bitcoin/blob/6a97e8a060f7632bbaee27d3de8035dc6ebe3895/src/test/transaction_tests.cpp#L758-L762 It turned out that `IsStandardTx()` returned `"dust"` as rejection reason (instead of the expected `"multi-op-return"`), leading to the conclusion that https://github.com/bitcoin/bitcoin/pull/17272/commits/5fe6f052bd37a16b2849e05f5cf18d7e194bc705 erroneously performs the `IsDust()` check also for TX_NULL_DATA transactions. To avoid cases like this in the future, this PR makes the unit test `test_IsStandard` more strict by also checking for the concrete reason after each occurence of `IsStandardTx()` returning false. ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17299/commits/c1c6c410a66996b2d60d5172189b5a5ec8100842 Tree-SHA512: c7419884cc52977c73f8f8c476eaebed80ba7bda4d03509d3f46dd977be911389f7b53daefa5ef31d2f7df9402243152e01e83f1b8a9fb300c19d1a0f69a89a9
2019-10-29[validation] Remove fMissingInputs from AcceptToMemoryPool()John Newbery
Handle this failure in the same way as all other failures: call Invalid() with the reasons for the failure.
2019-10-29[validation] Remove unused first_invalid parameter from ProcessNewBlockHeaders()John Newbery
No callers use the returned value in first_invalid. Remove it from the function signature and don't set it in the function.
2019-10-29[validation] Add CValidationState subclassesJohn Newbery
Split CValidationState into TxValidationState and BlockValidationState to store validation results for transactions and blocks respectively.
2019-10-29test: add reason checks for non-standard txs in test_IsStandardSebastian Falbesoner
2019-10-29Merge #17260: Split some CWallet functions into new LegacyScriptPubKeyManMarcoFalke
f201ba59ffd2e071a36a688b80d2cff9a9c44bb2 Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes (Andrew Chow) 6702048f91089d7a565e5ca5f7c8dcd2ca405a85 MOVEONLY: Move key handling code out of wallet to keyman file (Andrew Chow) ab053ec6d1e766402f88947d29cd875a285e7280 Move wallet enums to walletutil.h (Andrew Chow) Pull request description: Moves key management functions into a new class LegacyScriptPubKeyMan. First two commits are move-only commits which move stuff out of wallet.{h/cpp} and into newly created scriptpubkeyman.{h/cpp}. Third commit changes several things in CWallet to use LegacyScriptPubKeyMan. First step in the wallet boxes refactor. Note that LegacyScriptPubKeyMan and ScriptPubKeyMan cannot be used standalone yet and are still very much tied into CWallet with both accessing functions within each other. This PR is to help reduce review burden. ACKs for top commit: Sjors: Code review ACK f201ba5. promag: Code review ACK f201ba59ffd2e071a36a688b80d2cff9a9c44bb2. ryanofsky: Code review ACK f201ba59ffd2e071a36a688b80d2cff9a9c44bb2 MarcoFalke: ACK f201ba59ffd2e071a36a688b80d2cff9a9c44bb2 Tree-SHA512: bdc0d8595a06233fe003afcf968a38e0e8cc584a6a89c5bcd05309ac29dca852391802d46763ef81a108d146d0f40c79ea5438e87234ed12b4b8360c9aec94c0
2019-10-28Merge #17266: util: Rename DecodeDumpTime to ParseISO8601DateTimeMarcoFalke
e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd Add roundtrip and more tests to ParseISO8601DateTime and FormatISO8601DateTime (Elichai Turkel) 9e2c623be50ee7e586a411923b9ed136acfa2b3f Rename DecodeDumpTime to ParseISO8601DateTime and move to time.cpp (Elichai Turkel) Pull request description: As discussed in #17245. 1. Renamed the function. 2. Moved it from `rpcdump.cpp` to `time.cpp`. 3. Added a check if the time is less then epoch return 0 to prevent an overflow. 4. Added more edge cases tests and a roundtrip test. ACKs for top commit: laanwj: ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd MarcoFalke: ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd promag: Code review ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd. Moved code is correct, left a comment regarding the test change. Tree-SHA512: 703c21e09b2aabc992235149e67acba63d9d77a593ec8f6d2fec3eb63a7e5c406d56cbce6c6513ab32fba43367d073d2345f3b589843e3c5fe4f55ea3e00bf29
2019-10-28Avoid using g_rpc_node global in wallet codeRussell Yanofsky
Wallet code should use interfaces::Chain and not directly access to node state. Add a g_rpc_chain replacement global for wallet code to use, and move g_rpc_node definition to a libbitcoin_server source file so there are link errors if wallet code tries to access it.
2019-10-28scripted-diff: Remove g_connman, g_banman globalsRussell Yanofsky
-BEGIN VERIFY SCRIPT- sed -i 's:#include <interfaces/chain.h>:#include <banman.h>\n#include <interfaces/chain.h>\n#include <net.h>\n#include <net_processing.h>:' src/node/context.cpp sed -i 's/namespace interfaces {/class BanMan;\nclass CConnman;\nclass PeerLogicValidation;\n&/' src/node/context.h sed -i 's/std::unique_ptr<interfaces::Chain> chain/std::unique_ptr<CConnman> connman;\n std::unique_ptr<PeerLogicValidation> peer_logic;\n std::unique_ptr<BanMan> banman;\n &/' src/node/context.h sed -i '/std::unique_ptr<[^>]\+> \(g_connman\|g_banman\|peerLogic\);/d' src/banman.h src/net.h src/init.cpp sed -i 's/g_connman/m_context.connman/g' src/interfaces/node.cpp sed -i 's/g_banman/m_context.banman/g' src/interfaces/node.cpp sed -i 's/g_connman/m_node.connman/g' src/interfaces/chain.cpp src/test/setup_common.cpp sed -i 's/g_banman/m_node.banman/g' src/test/setup_common.cpp sed -i 's/g_connman/node.connman/g' src/init.cpp src/node/transaction.cpp sed -i 's/g_banman/node.banman/g' src/init.cpp sed -i 's/peerLogic/node.peer_logic/g' src/init.cpp sed -i 's/g_connman/g_rpc_node->connman/g' src/rpc/mining.cpp src/rpc/net.cpp src/rpc/rawtransaction.cpp sed -i 's/g_banman/g_rpc_node->banman/g' src/rpc/net.cpp sed -i 's/std::shared_ptr<CWallet> wallet =/node.context()->connman = std::move(test.m_node.connman);\n &/' src/qt/test/wallettests.cpp -END VERIFY SCRIPT-
2019-10-28Pass NodeContext, ConnMan, BanMan references more placesRussell Yanofsky
So g_connman and g_banman globals can be removed next commit.
2019-10-28scripted-diff: Rename InitInterfaces to NodeContextRussell Yanofsky
-BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'struct InitInterfaces' 'struct NodeContext' s 'InitInterfaces interfaces' 'NodeContext node' s 'InitInterfaces& interfaces' 'NodeContext\& node' s 'InitInterfaces m_interfaces' 'NodeContext m_context' s 'InitInterfaces\* g_rpc_interfaces' 'NodeContext* g_rpc_node' s 'g_rpc_interfaces = &interfaces' 'g_rpc_node = \&node' s 'g_rpc_interfaces' 'g_rpc_node' s 'm_interfaces' 'm_context' s 'interfaces\.chain' 'node.chain' s '\(AppInitMain\|Shutdown\|Construct\)(interfaces)' '\1(node)' s 'init interfaces' 'chain clients' -END VERIFY SCRIPT-
2019-10-28Merge #16986: doc: Doxygen-friendly CuckooCache commentsfanquake
7aad3b68e7e1680870ca70d945eee88f790d6454 doc: Doxygen-friendly CuckooCache comments (Jon Layton) Pull request description: Similar theme to #16947. - `invalid`, `contains` now appear in Doxygen docs - `setup` refers to correct argument name `b` - Argument references in `code blocks ` - Lists markdown conformant, uniform line endings Tested with `make docs` ACKs for top commit: laanwj: ACK 7aad3b68e7e1680870ca70d945eee88f790d6454 practicalswift: ACK 7aad3b68e7e1680870ca70d945eee88f790d6454 Tree-SHA512: 70b38c10e534bad9c6ffcd88cc7a4797644afba5956d47a6c7cc655fcd5857a91f315d6da60e28ce9678d420ed4a51e22267eb8b89e26002b99cad63373dd349
2019-10-27tests: Add fuzzer initialization (hold ECCVerifyHandle)practicalswift
2019-10-27Add roundtrip and more tests to ParseISO8601DateTime and FormatISO8601DateTimeElichai Turkel
2019-10-25Refactor: Split up CWallet and LegacyScriptPubKeyMan and classesAndrew Chow
This moves CWallet members and methods dealing with keys to a new LegacyScriptPubKeyMan class, and updates calling code to reference the new class instead of CWallet. Most of the changes are simple text replacements and variable substitutions easily verified with: git log -p -n1 -U0 --word-diff-regex=. The only nontrivial chunk of code added is the new LegacyScriptPubKeyMan class declaration, but this code isn't new and is just selectively copied and moved from the previous CWallet class declaration. This can be verified with: git log -p -n1 --color-moved=dimmed_zebra src/wallet/scriptpubkeyman.h src/wallet/wallet.h or git diff HEAD~1:src/wallet/wallet.h HEAD:src/wallet/scriptpubkeyman.h This commit does not change behavior.
2019-10-25test: fix script_p2sh_tests OP_PUSHBACK2/4 missingkodslav
Fixes commit 6b25f29a91 where opcodes where lost in translation.
2019-10-25Merge #17083: tests: Add fuzzing harness for various CScript related functionsMarcoFalke
dc2fdb99072b87d34620084b82a494a5e698c279 tests: Add fuzzing harness for various CScript related functions (practicalswift) Pull request description: Add fuzzing harness for various `CScript` related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/script … # And to to quickly verify that the relevant code regions are triggered, that the # fuzzing throughput seems reasonable, etc. $ contrib/devtools/test_fuzzing_harnesses.sh '^script$' ``` `test_fuzzing_harnesses.sh` can be found in PR #17000. Top commit has no ACKs. Tree-SHA512: a0c5dca3b64ae177020b2ca299a29015d70755231b6bf01edbfc67c8aac90c44b1b4d57350c3aebef6e031108e6ae8e5fa0987c67707831c314f5d3090e0cee8
2019-10-25Merge #17220: tests: Add unit testing for the CompressScript functionWladimir J. van der Laan
b05ec410f2d9f209796a5df31860e23efd729dfe Add unit testing for the CompressScript functions (marcaiaf) Pull request description: Salvaging #15104 which adds unit tests for CompressScript function in `compressor.cpp` Tested following cases for the CScript: - CKeyID - CScriptID - Uncompressed CPubKey (of size: 65) - Compressed CPubKey (of size: 32) ACKs for top commit: theStack: ACK https://github.com/bitcoin/bitcoin/commit/b05ec410f2d9f209796a5df31860e23efd729dfe Tree-SHA512: 7e23ace39383122802dfe5f7d38190d772f5db4045a67b7a9bd4c06797a17e0cdc41d6fac92d448057eb7df50172155dc824587c16c68c79fd1a4de37b772001
2019-10-25Merge #17080: consensus: Explain why fCheckDuplicateInputs can not be ↵Wladimir J. van der Laan
skipped and remove it fa928134075220254a15107c1d9702f4e66271f8 consensus: Explain why fCheckDuplicateInputs can not be skipped and remove it (MarcoFalke) Pull request description: As a follow up to CVE-2018-17144, this removes the unused `fCheckDuplicateInputs` parameter and explains why the test can not be disabled. Apart from protecting against a dumb accident in the future, this should document the logic in the code. There is a technical write-up that explains how the underlying coins database behaves if this test is skipped: https://bitcoincore.org/en/2018/09/20/notice/#technical-details. However, it does not explicitly mention why the test can not be skipped. I hope my code comment does that. ACKs for top commit: jnewbery: ACK fa928134075220254a15107c1d9702f4e66271f8 amitiuttarwar: utACK fa928134075220254a15107c1d9702f4e66271f8 Empact: Code review ACK https://github.com/bitcoin/bitcoin/commit/fa928134075220254a15107c1d9702f4e66271f8 promag: ACK fa928134075220254a15107c1d9702f4e66271f8. Tree-SHA512: fc1ef670f1a467c543b84f704b9bd8cc7a59a9f707be048bd9b4e85fe70830702aa560a880efa2c840bb43818ab44dfdc611104df04db2ddc14ff92f46bfb28e
2019-10-25tests: Add fuzzing harness for various CScript related functionspracticalswift
2019-10-24Merge #17212: refactor: Remove unused CExt{Pub,}Key (de)serialization methodsMarcoFalke
5b44a75493a1a098404d5e21dc384e74eae1892e refactor: Remove unused CExt{Pub,}Key (de)serialization methods (Sebastian Falbesoner) Pull request description: As pointed out in issue #17130, the serialization/deserialization methods for the classes `CExtKey` and `CExtPubKey` are only used in the BIP32 unit tests and hence can be removed (see comments https://github.com/bitcoin/bitcoin/issues/17130#issuecomment-543750290, https://github.com/bitcoin/bitcoin/issues/17130#issuecomment-543794408 and https://github.com/bitcoin/bitcoin/issues/17130#issuecomment-543814727). ACKs for top commit: practicalswift: ACK 5b44a75493a1a098404d5e21dc384e74eae1892e -- -60 LOC diff looks correct :) promag: ACK 5b44a75493a1a098404d5e21dc384e74eae1892e. MarcoFalke: unsigned ACK 5b44a75493a1a098404d5e21dc384e74eae1892e fjahr: ACK 5b44a75 jonatack: Light ACK 5b44a75493a1a098404d5e21dc384e74eae1892e. Built, ran tests and bitcoind. `git blame` shows most of the last changes are from commit 90604f16af63ec066d6561337f476ccd8acec326 in 2015 to add bip32 pubkey serialization. Tree-SHA512: 6887573b76b9e54e117a076557407b6f7908719b2202fb9eea498522baf9f30198b3f78b87a62efcd17ad1ab0886196f099239992ce7cbbaee79979ffe9e5f2c
2019-10-24consensus: Explain why fCheckDuplicateInputs can not be skipped and remove itMarcoFalke
2019-10-24tests: Remove Cygwin WinMain workaroundpracticalswift
2019-10-24tests: Skip unnecessary fuzzer initialisation. Hold ECCVerifyHandle only ↵practicalswift
when needed.
2019-10-23Merge #17206: test: Add testcase to simulate bitcoin schema in leveldbMarcoFalke
4896bacc00549c14f3284f5a2b61fb848ac31be0 Add testcase to simulate bitcoin schema in leveldb (MapleLaker) Pull request description: Resurrecting #14125 with updates based on comments of closed PR ACKs for top commit: laanwj: ACK 4896bacc00549c14f3284f5a2b61fb848ac31be0 dongcarl: ACK 4896bacc00549c14f3284f5a2b61fb848ac31be0 Tree-SHA512: 3290ea7e1e998901d5ee8921d1d76cec399cae30ac1911a45b86826afed47cee1acf92bd6438f1fa11ed785a3b17abdcb1c169bc0419945eda9fe4c089d0b6eb
2019-10-23Add unit testing for the CompressScript functionsmarcaiaf
2019-10-23Merge #17018: tests: Add descriptor Parse(...) fuzzing harnessMarcoFalke
b5ffa9f3dbff7dd008d4d00a88590d411ef991f2 tests: Add Parse(...) (descriptor) fuzzing harness (practicalswift) fdef8bbf2f824a87f70b755155e9e1a8cd19fdcb tests: Allow for using non-default fuzzing initialization (practicalswift) Pull request description: Add `Parse(...)` (descriptor) fuzzing harness. To test this PR: We can run `test_fuzzing_harnesses.sh` (#17000) during ten seconds to quickly verify that the newly added fuzz harness seem to hit relevant code regions, that the fuzzing throughput seems reasonable, etc. `test_fuzzing_harnesses.sh descriptor 10` runs all fuzzers matching the regexp `descriptor` giving them ten seconds of runtime each. ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined $ make $ contrib/devtools/test_fuzzing_harnesses.sh descriptor 10 Testing fuzzer descriptor_parse during 10 second(s) A subset of reached functions: NEW_FUNC[0/17]: 0x55ec8a240c90 in tinyformat::detail::formatImpl(std::ostream&, char const*, tinyformat::detail::FormatArg const*, int) src/./tinyformat.h:791 NEW_FUNC[4/17]: 0x55ec8a2435f0 in tinyformat::detail::printFormatStringLiteral(std::ostream&, char const*) src/./tinyformat.h:564 NEW_FUNC[5/17]: 0x55ec8a2439d0 in tinyformat::detail::streamStateFromFormat(std::ostream&, bool&, int&, char const*, tinyformat::detail::FormatArg const*, int&, int) src/./tinyformat.h:601 NEW_FUNC[6/17]: 0x55ec8a24a3d0 in tinyformat::detail::FormatArg::format(std::ostream&, char const*, char const*, int) const src/./tinyformat.h:513 NEW_FUNC[12/17]: 0x55ec8a29cd70 in void tinyformat::detail::FormatArg::formatImpl<long>(std::ostream&, char const*, char const*, int, void const*) src/./tinyformat.h:530 NEW_FUNC[13/17]: 0x55ec8a29cf50 in void tinyformat::formatValue<long>(std::ostream&, char const*, char const*, int, long const&) src/./tinyformat.h:317 NEW_FUNC[14/17]: 0x55ec8a2ea450 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<long>(char const*, long const&) src/./tinyformat.h:976 NEW_FUNC[15/17]: 0x55ec8a346ac0 in void tinyformat::format<long>(std::ostream&, char const*, long const&) src/./tinyformat.h:968 NEW_FUNC[16/17]: 0x55ec8a346d80 in tinyformat::detail::FormatListN<1>::FormatListN<long>(long const&) src/./tinyformat.h:885 NEW_FUNC[0/16]: 0x55ec8a210c90 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:976 NEW_FUNC[2/16]: 0x55ec8a25c3e0 in void tinyformat::format<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::ostream&, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:968 NEW_FUNC[3/16]: 0x55ec8a25c6a0 in tinyformat::detail::FormatListN<1>::FormatListN<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:885 NEW_FUNC[4/16]: 0x55ec8a25c980 in void tinyformat::detail::FormatArg::formatImpl<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::ostream&, char const*, char const*, int, void const*) src/./tinyformat.h:530 NEW_FUNC[6/16]: 0x55ec8b29cc60 in (anonymous namespace)::ParseScript(Span<char const>&, (anonymous namespace)::ParseScriptContext, FlatSigningProvider&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) src/script/descriptor.cpp:810 NEW_FUNC[8/16]: 0x55ec8b2a4710 in (anonymous namespace)::Expr(Span<char const>&) src/script/descriptor.cpp:657 NEW_FUNC[9/16]: 0x55ec8b2a4d40 in (anonymous namespace)::Func(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Span<char const>&) src/script/descriptor.cpp:647 NEW_FUNC[15/16]: 0x55ec8b2d7dd0 in Span<char const>::subspan(long) const src/./span.h:33 NEW_FUNC[0/1]: 0x55ec8b2d7830 in Span<char const>::operator[](long) const src/./span.h:31 NEW_FUNC[0/10]: 0x55ec8a2ea090 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<char const*>(char const*, char const* const&) src/./tinyformat.h:976 NEW_FUNC[1/10]: 0x55ec8a345d40 in void tinyformat::format<char const*>(std::ostream&, char const*, char const* const&) src/./tinyformat.h:968 NEW_FUNC[2/10]: 0x55ec8a346000 in tinyformat::detail::FormatListN<1>::FormatListN<char const*>(char const* const&) src/./tinyformat.h:885 NEW_FUNC[3/10]: 0x55ec8a3462e0 in void tinyformat::detail::FormatArg::formatImpl<char const*>(std::ostream&, char const*, char const*, int, void const*) src/./tinyformat.h:530 NEW_FUNC[4/10]: 0x55ec8a3464b0 in void tinyformat::formatValue<char const*>(std::ostream&, char const*, char const*, int, char const* const&) src/./tinyformat.h:317 NEW_FUNC[8/10]: 0x55ec8b438ef0 in ParsePrechecks(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/util/strencodings.cpp:267 NEW_FUNC[9/10]: 0x55ec8b4398b0 in ParseUInt32(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int*) src/util/strencodings.cpp:309 NEW_FUNC[0/3]: 0x55ec8a2e9430 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tinyformat::format<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:976 NEW_FUNC[1/3]: 0x55ec8a33a6f0 in void tinyformat::format<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::ostream&, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:968 NEW_FUNC[2/3]: 0x55ec8a33aa40 in tinyformat::detail::FormatListN<2>::FormatListN<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/./tinyformat.h:885 NEW_FUNC[1/2]: 0x55ec8b4331b0 in IsHex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/util/strencodings.cpp:61 NEW_FUNC[13/24]: 0x55ec8b126eb0 in Params() src/chainparams.cpp:384 NEW_FUNC[14/24]: 0x55ec8b19a500 in DecodeDestination(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/key_io.cpp:217 NEW_FUNC[15/24]: 0x55ec8b19a610 in (anonymous namespace)::DecodeDestination(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CChainParams const&) src/key_io.cpp:74 NEW_FUNC[18/24]: 0x55ec8b357160 in IsValidDestination(boost::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown> const&) src/script/standard.cpp:325 NEW_FUNC[19/24]: 0x55ec8b36fe40 in DecodeBase58(char const*, std::vector<unsigned char, std::allocator<unsigned char> >&) src/base58.cpp:36 stat::number_of_executed_units: 54900 stat::average_exec_per_sec: 4990 stat::new_units_added: 421 stat::slowest_unit_time_sec: 0 stat::peak_rss_mb: 412 Number of unique code paths taken during fuzzing round: 93 Tested fuzz harnesses seem to work as expected. ``` Top commit has no ACKs. Tree-SHA512: f18d0a6798c55d2c85ef9e604af2c1d626da2b81c01ea3f77c5cecd4ce35b197030778b3cfebab4869dab84a022325dba94fd83290026bfbc59814938e1daa02
2019-10-23Merge #17183: refactor: test/bench: dedup Build{Crediting,Spending}Transaction()MarcoFalke
a0fc0764763329df2c4b11a4e22715ccfc0cf7d3 refactor: test/bench: dedup Build{Crediting,Spending}Transaction() (Sebastian Falbesoner) Pull request description: prototypes used in `src/test/script_tests.cpp`: - `CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue = 0);` - `CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit);` prototypes used in `bench/verify_script.cpp`: - `CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey);` - `CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMutableTransaction& txCredit);` The more generic versions from the script tests are moved into `setup_common.cpp` and the calls are adapted accordingly in the verify_script benchmark (passing the nValue of 1 explicitely for `BuildCreditingTransaction()`, passing empty scriptWitness explicitely and converting txCredit parameter to CTransaction in `BuildSpendingTransaction()`). Top commit has no ACKs. Tree-SHA512: 8444f8a18f15070eeec1e5dfd255b55a851dfc2e6647c12b1995a6f7abd7196e830db2181d0e860bcd4cf4c815967584a3756dd450346bca70649dd1d4493e04
2019-10-23tests: Add Parse(...) (descriptor) fuzzing harnesspracticalswift
2019-10-23tests: Allow for using non-default fuzzing initializationpracticalswift
2019-10-23refactor: test/bench: dedup Build{Crediting,Spending}Transaction()Sebastian Falbesoner
prototypes used in src/test/script_tests.cpp: - CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue = 0); - CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit); prototypes used in bench/verify_script.cpp: - CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey); - CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMutableTransaction& txCredit); The more generic versions from the script tests are moved into a new file pair transaction_utils.cpp/h and the calls are adapted accordingly in the verify_script benchmark (passing the nValue of 1 explicitely for BuildCreditingTransaction(), passing empty scriptWitness explicitely and converting txCredit parameter to CTransaction in BuildSpendingTransaction()).
2019-10-22refactor: Remove unused CExt{Pub,}Key (de)serialization methodsSebastian Falbesoner
The serialization/deserialization methods for the classes CExtKey and CExtPubKey were only used in the BIP32 unit tests, where the relevant parts are removed as well.
2019-10-21Add testcase to simulate bitcoin schema in leveldbMapleLaker
2019-10-18Merge #16889: Add some general std::vector utility functionsMarcoFalke
7d8d3e6a2ad827fa916e3909a18dedb9f7fdce43 Add tests for util/vector.h's Cat and Vector (Pieter Wuille) e65e61c812df90a56e3ce4a8e76c4b746766f387 Add some general std::vector utility functions (Pieter Wuille) Pull request description: This is another general improvement extracted from #16800 . Two functions are added are: * Vector(arg1,arg2,arg3,...) constructs a vector with the specified arguments as elements. The vector's type is derived from the arguments. If some of the arguments are rvalue references, they will be moved into place rather than copied (which can't be achieved using list initialization). * Cat(vector1,vector2) returns a concatenation of the two vectors, efficiently moving elements when relevant. Vector generalizes (and replaces) the `Singleton` function in src/descriptor.cpp, and `Cat` replaces the function in bech32.cpp ACKs for top commit: laanwj: ACK 7d8d3e6a2ad827fa916e3909a18dedb9f7fdce43 MarcoFalke: ACK 7d8d3e6a2ad827fa916e3909a18dedb9f7fdce43 (enjoyed reading the tests, but did not compile) Tree-SHA512: 92325f14e90d7e7d9d920421979aec22bb0d730e0291362b4326cccc76f9c2d865bec33a797c5c0201773468c3773cb50ce52c8eee4c1ec1a4d10db5cf2b9d2a
2019-10-17Merge #17140: test: Fix bug in blockfilter_index_tests.MarcoFalke
f59bbb61af5055844c16939a4f8e58c4f73843c1 test: Fix bug in blockfilter_index_tests. (Jim Posen) Pull request description: The test case tests a chain reorganization, however the two chains were generated in the same manner and thus produced the same blocks. This issue was [pointed out](https://github.com/bitcoin/bitcoin/pull/14121#discussion_r334282663) by MarcoFalke. ACKs for top commit: MarcoFalke: Thanks! ACK f59bbb61af5055844c16939a4f8e58c4f73843c1 (looked at the diff on GitHub, didn't compile, nor run tests) Tree-SHA512: a2f063ae9312051ffc2a3fcc1116a6a8ac09beeef261bc40aa3ff7270ff4de22a790eb19fec6b15ba1eb46e78f1f317bfd91472d8581b95bb9441a56b102554e
2019-10-16Merge #16659: refactoring: Remove unused includesMarcoFalke
084e17cebd424b8e8ced674bc810eef4e6ee5d3b Remove unused includes (practicalswift) Pull request description: As requested by MarcoFalke in https://github.com/bitcoin/bitcoin/pull/16273#issuecomment-521332089: This PR removes unused includes. Please note that in contrast to #16273 I'm limiting the scope to the trivial cases of pure removals (i.e. no includes added) to make reviewing easier. I'm seeking "Concept ACK":s for this obviously non-urgent minor cleanup. Rationale: * Avoids unnecessary re-compiles in case of header changes. * Makes reasoning about code dependencies easier. * Reduces compile-time memory usage. * Reduces compilation time. * Warm fuzzy feeling of being lean :-) ACKs for top commit: ryanofsky: Code review ACK 084e17cebd424b8e8ced674bc810eef4e6ee5d3b. PR only removes include lines and it still compiles. In the worst case someone might have to explicitly add an include later for something now included implicitly. But maybe some effort was taken to avoid this, and it wouldn't be a tragedy anyway. Tree-SHA512: 89de56edc6ceea4696e9579bccff10c80080821685b9fb4e8c5ef593b6e43cf662f358788701bb09f84867693f66b2e4db035b92b522a0a775f50b7ecffd6a6d
2019-10-16Add tests for util/vector.h's Cat and VectorPieter Wuille
2019-10-16Merge #17095: util: Filter control characters out of log messagesWladimir J. van der Laan
d7820a1250070f3640246ae497e049bee0b3516f util: Filter control characters out of log messages (Wladimir J. van der Laan) Pull request description: Belts and suspenders: make sure outgoing log messages don't contain potentially suspicious characters, such as terminal control codes. This escapes control characters except newline ('\n') in C syntax. It escapes instead of removes them to still allow for troubleshooting issues where they accidentally end up in strings (it is a debug log, after all). (more checks could be added such as UTF-8 validity and unicode code-point range checking—this is substantially more involved and would need to keep track of state between characters and even `LogPrint` calls as they could end up split up—but escape codes seem to be the most common attack vector for terminals.) ACKs for top commit: practicalswift: ACK d7820a1250070f3640246ae497e049bee0b3516f - tested and works as expected :) Tree-SHA512: 0806265addebdcec1062a6def3e903555e62ba5e93967ce9ee6943d16462a222b3f41135a5bff0a76966ae9e7ed75f211d7785bceda788ae0b0654bf3fd891bf
2019-10-15Remove unused includespracticalswift
2019-10-15tests: Add fuzzing harness for descriptor Span-parsing helperspracticalswift
2019-10-15tests: Fix fs_tests for unknown localesDaki Carnhof
Fix by removing "L" as suggested by meeDamian in https://github.com/bitcoin/bitcoin/issues/14948#issuecomment-522355441 Co-Authored-By: bugs@meedamian.com
2019-10-15util: Filter control characters out of log messagesWladimir J. van der Laan
Belts and suspenders: make sure outgoing log messages don't contain potentially suspicious characters, such as terminal control codes. This escapes control characters except newline ('\n') in C syntax. It escapes instead of removes them to still allow for troubleshooting issues where they accidentally end up in strings.
2019-10-14test: Fix bug in blockfilter_index_tests.Jim Posen
The test case tests a chain reorganization, however the two chains were generated in the same manner and thus produced the same blocks.