aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* Removes Boost predicate.hpp dependency2512018-07-221-0/+15
| | | | | | | | | | | | | This is a squashed commit that squashes the following commits: This commit removes the `boost/algorithm/string/predicate.hpp` dependenc from the project by replacing the function calls to `boost::algorithm::starts_with` `boost::algorithm::ends_with` and `all` with respectively C++11' `std::basic_string::front`, `std::basic_string::back`, `std::all_of` function calls This commit replaces `boost::algorithm::is_digit` with a locale independent isdigi function, because the use of the standard library's `isdigit` and `std::isdigit functions is discoraged in the developer notes
* Use common SetDataDir method to create temp directory in tests.winder2018-07-111-4/+4
|
* Give an error and exit if there are unknown parametersAndrew Chow2018-05-301-23/+44
| | | | | | | | | | | If an unknown option is given via either the command line args or the conf file, throw an error and exit Update tests for ArgsManager knowing args Ignore unknown options in the config file for bitcoin-cli Fix tests and bitcoin-cli to match actual options used
* Merge #12963: Fix Clang Static Analyzer warningsMarcoFalke2018-05-141-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 159c32d1f1 Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. (practicalswift) fd447a6efe Fix dead stores. Values were stored but never read. Limit scope. (practicalswift) Pull request description: Fix Clang Static Analyzer warnings reported by @kallewoof in #12961: * Fix dead stores. Values were stored but never read. * Add assertion to guide static analyzers. See #12961 for details. Tree-SHA512: 83dbec821f45217637316bee978e7543f2d2caeb7f7b0b3aec107fede0fff8baa756da8f6b761ae0d38537740839ac9752f6689109c38a4b05c0c041aaa3a1fb
| * Fix dead stores. Values were stored but never read. Limit scope.practicalswift2018-04-121-0/+1
| |
* | trivial: Fix relevent typopracticalswift2018-04-221-1/+1
| |
* | Merge #11862: Network specific conf sectionsWladimir J. van der Laan2018-04-161-63/+189
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c25321f Add config changes to release notes (Anthony Towns) 5e3cbe0 [tests] Unit tests for -testnet/-regtest in [test]/[regtest] sections (Anthony Towns) 005ad26 ArgsManager: special handling for -regtest and -testnet (Anthony Towns) 608415d [tests] Unit tests for network-specific config entries (Anthony Towns) 68797e2 ArgsManager: Warn when ignoring network-specific config setting (Anthony Towns) d1fc4d9 ArgsManager: limit some options to only apply on mainnet when in default section (Anthony Towns) 8a9817d [tests] Use regtest section in functional tests configs (Anthony Towns) 30f9407 [tests] Unit tests for config file sections (Anthony Towns) 95eb66d ArgsManager: support config file sections (Anthony Towns) 4d34fcc ArgsManager: drop m_negated_args (Anthony Towns) 3673ca3 ArgsManager: keep command line and config file arguments separate (Anthony Towns) Pull request description: The weekly meeting on [2017-12-07](http://www.erisian.com.au/meetbot/bitcoin-core-dev/2017/bitcoin-core-dev.2017-12-07-19.00.log.html) discussed allowing options to bitcoin to have some sensitivity to what network is in use. @theuni suggested having sections in the config file: <cfields> an alternative to that would be sections in a config file. and on the cmdline they'd look like namespaces. so, [testnet] port=5. or -testnet::port=5. This approach is (more or less) supported by `boost::program_options::detail::config_file_iterator` -- when it sees a `[testnet]` section with `port=5`, it will treat that the same as "testnet.port=5". So `[testnet] port=5` (or `testnet.port=5` without the section header) in bitcoin.conf and `-testnet.port=5` on the command line. The other aspect to this question is possibly limiting some options so that there is no possibility of accidental cross-contamination across networks. For example, if you're using a particular wallet.dat on mainnet, you may not want to accidentally use the same wallet on testnet and risk reusing keys. I've set this up so that the `-addnode` and `-wallet` options are `NETWORK_ONLY`, so that if you have a bitcoin.conf: wallet=/secret/wallet.dat upnp=1 and you run `bitcoind -testnet` or `bitcoind -regtest`, then the `wallet=` setting will be ignored, and should behave as if your bitcoin.conf had specified: upnp=1 [main] wallet=/secret/wallet.dat For any `NETWORK_ONLY` options, if you're using `-testnet` or `-regtest`, you'll have to add the prefix to any command line options. This was necessary for `multiwallet.py` for instance. I've left the "default" options as taking precedence over network specific ones, which might be backwards. So if you have: maxmempool=200 [regtest] maxmempool=100 your maxmempool will still be 200 on regtest. The advantage of doing it this way is that if you have `[regtest] maxmempool=100` in bitcoin.conf, and then say `bitcoind -regtest -maxmempool=200`, the same result is probably in line with what you expect... The other thing to note is that I'm using the chain names from `chainparamsbase.cpp` / `ChainNameFromCommandLine`, so the sections are `[main]`, `[test]` and `[regtest]`; not `[mainnet]` or `[testnet]` as might be expected. Thoughts? Ping @MeshCollider @laanwj @jonasschnelli @morcos Tree-SHA512: f00b5eb75f006189987e5c15e154a42b66ee251777768c1e185d764279070fcb7c41947d8794092b912a03d985843c82e5189871416995436a6260520fb7a4db
| * | [tests] Unit tests for -testnet/-regtest in [test]/[regtest] sectionsAnthony Towns2018-04-111-1/+26
| | |
| * | [tests] Unit tests for network-specific config entriesAnthony Towns2018-04-111-3/+34
| | |
| * | [tests] Unit tests for config file sectionsAnthony Towns2018-04-111-2/+60
| | |
| * | ArgsManager: drop m_negated_argsAnthony Towns2018-04-111-29/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a -nofoo option is seen, instead of adding it to a separate set of negated args, set the arg as being an empty vector of strings. This changes the behaviour in some ways: - -nofoo=0 still sets foo=1 but no longer treats it as a negated arg - -nofoo=1 -foo=2 has GetArgs() return [2] rather than [2,0] - "foo=2 \n -nofoo=1" in a config file no longer returns [2,0], just [0] - GetArgs returns an empty vector for negated args
| * | ArgsManager: keep command line and config file arguments separateAnthony Towns2018-04-111-31/+52
| |/
* / Avoid std::locale/imbue in DateTimeStrFormatPieter Wuille2018-04-131-11/+0
|/
* Merge #11851: scripted-diff: Rename wallet database classesWladimir J. van der Laan2018-04-091-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9b0f0c5 Add m_ prefix to WalletBatch::m_batch (Russell Yanofsky) 398c6f0 Update walletdb comment after renaming. (Russell Yanofsky) ea23945 scripted-diff: Rename wallet database classes (Russell Yanofsky) Pull request description: Scripted diff to rename some wallet classes. Motivated by discussion in https://github.com/bitcoin/bitcoin/pull/11687#discussion_r155354119 | Current | New | | ---------------- | ------------------- | | CDBEnv | BerkeleyEnvironment | | CDB | BerkeleyBatch | | CWalletDBWrapper | WalletDatabase | | CWalletDB | WalletBatch | Berkeley\* classes are intended to contain BDB specific code, while Wallet\* classes are intended to be more backend-agnostic. Also renamed associated variables: | Current | New | | ------------------- | --------------- | | dbw | database | | pwalletdb | batch | | pwalletdbEncryption | encrypted_batch | Tree-SHA512: 372f2e24b2deb59d4792b5ed578aaf0cce51b6db41c400bef5d0c2cd7833e62ae4d4afa0f6000268d52e15b20f737c5a55f1cecf7768556a782fd8cd6fe051d9
| * scripted-diff: Rename wallet database classesRussell Yanofsky2018-04-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; } ren CDBEnv BerkeleyEnvironment ren CDB BerkeleyBatch ren CWalletDBWrapper WalletDatabase ren CWalletDB WalletBatch ren dbw database ren m_dbw m_database ren walletdb batch ren pwalletdb batch ren pwalletdbIn batch_in ren wallet/batch.h wallet/walletdb.h ren pwalletdbEncryption encrypted_batch -END VERIFY SCRIPT-
* | [tests] Add additional unit tests for -nofoo edge casesAnthony Towns2018-04-061-2/+38
| |
* | [tests] Check GetChainName works with config entriesAnthony Towns2018-04-061-0/+23
| |
* | [tests] Add unit tests for ReadConfigStreamAnthony Towns2018-04-061-0/+107
| |
* | [tests] Add unit tests for GetChainNameAnthony Towns2018-04-061-0/+25
|/
* Merge #12713: Track negated options in the option parserMarcoFalke2018-03-301-10/+52
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | f7683cba7b Track negated arguments in the argument paser. (Evan Klitzke) 4f872b2450 Add additional tests for GetBoolArg() (Evan Klitzke) Pull request description: This change explicitly enable tracking negated options in the option parser. A negated option is one passed with a `-no` prefix. For example, `-nofoo` is the negated form of `-foo`. Negated options were originally added in the 0.6 release. The change here allows code to explicitly distinguish between cases like `-nofoo` and `-foo=0`, which was not possible previously. The option parser does not have any changed semantics as a result of this change, and existing code will parse options just as it did before. The motivation for this change is to provide a way to disable options that are otherwise not boolean options. For example, the `-debuglogfile` option is normally interpreted as a string, where the value is the log file name. With this change a user can pass in `-nodebuglogfile` and the code can see that it was explicitly negated, and use that to disable the log file. This change originally split out from #12689. Tree-SHA512: cd5a7354eb03d2d402863c7b69e512cad382781d9b8f18c1ab104fc46d45a712530818d665203082da39572c8a42313c5be09306dc2a7227cdedb20ef7314823
| * Track negated arguments in the argument paser.Evan Klitzke2018-03-271-10/+26
| | | | | | | | | | This commit adds tracking for negated arguments. This change will be used in a future commit that allows disabling the debug.log file using -nodebuglogfile.
| * Add additional tests for GetBoolArg()Evan Klitzke2018-03-271-0/+26
| | | | | | | | | | This is meant to be an intermediate commit to prove that the next does not introduce any changes in the semantics of boolean option parsing.
* | Reduce variable scopespracticalswift2018-03-261-2/+1
|/
* Merge #12630: Provide useful error message if datadir is not writable.Wladimir J. van der Laan2018-03-221-0/+16
|\ | | | | | | | | | | | | | | | | | | | | | | 8674e74 Provide relevant error message if datadir is not writable. (murrayn) Pull request description: If the --datadir exists, but is not writable, the current error message on startup is 'Cannot obtain a lock on data directory foo. Bitcoin Core is probably already running.' This is misleading. I believe this PR addresses #11668, although the issue is not Windows-specific. Tree-SHA512: 10cbbaea433072aee4fb3e8938a72073c7a5c841f7a7685c9e12549c322b2925c7d34bac254ac33021b23132bfc352c058712bc9542298cf86f8fd9757f528b2
| * Provide relevant error message if datadir is not writable.murrayn2018-03-141-0/+16
| |
* | Format timestamps using ISO 8601 formatting (e.g. "2018-02-28T12:34:56Z")practicalswift2018-03-091-0/+17
|/ | | | | | | | * Z is the zone designator for the zero UTC offset. * T is the delimiter used to separate date and time. This makes it clear for the end-user that the date/time logged is specified in UTC and not in the local time zone.
* Merge #12543: Fix typosMarcoFalke2018-03-051-2/+2
|\ | | | | | | | | | | | | | | | | | | d918eb7864 Fix typos (practicalswift) Pull request description: Fix typos. Tree-SHA512: c790e49be6e01c8d70ebd872ef61cc210c1de15c4a1e5a98280169f32dc8a14cd68f4dd1c23afc76758b28ef355ab12ded2ff7504562dc9b69a11839ad3cd7e3
| * Fix typospracticalswift2018-02-261-2/+2
| |
* | Merge #12570: Add test cases for HexStr (std::reverse_iterator and corner cases)Wladimir J. van der Laan2018-03-011-0/+66
|\ \ | |/ |/| | | | | | | | | | | | | ac48861 Add tests for HexStr std::reverse_iterator cases (Kosta Zertsekel) 90eac8c Add tests for HexStr corner cases (Kosta Zertsekel) Pull request description: Tree-SHA512: 6298d6fdc344e67a9ea6dc74eadb04e68f4f49fc4511d4a8765cafce7eeb8603f96ebedd82c13811326bcaf1ee511946419b651ca411f711baca91bec51947d6
| * Add tests for HexStr std::reverse_iterator casesKosta Zertsekel2018-03-011-0/+52
| | | | | | | | Signed-off-by: Kosta Zertsekel <[email protected]>
| * Add tests for HexStr corner casesKosta Zertsekel2018-03-011-0/+14
| | | | | | | | Signed-off-by: Kosta Zertsekel <[email protected]>
* | test: Add missing signal.h headerWladimir J. van der Laan2018-02-161-0/+1
| | | | | | | | | | | | util_tests.cpp needs to include the signal.h header on FreeBSD. Reported by denis2342 on IRC.
* | test: Add unit test for LockDirectoryWladimir J. van der Laan2018-02-151-0/+130
| | | | | | | | Add a unit test for LockDirectory, introduced in #11281.
* | Merge #11997: [tests] util_tests.cpp: actually check ignored argsMarcoFalke2018-01-041-1/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c99a3c32c8 [tests] util_tests.cpp: actually check ignored args (Anthony Towns) Pull request description: An array with 7 elements was setup for checking argument parsing, but was passed to ParseParamaeters with argc=5, meaning the interpretation of the last two arguments was never actually checked. Tree-SHA512: 7b81fde49742e524f1bb67e2ec084f5909ae36125f237f0210df4587c62e5a5a8f277f13543f0a85ad145c4bb80d62339a7d50d7ed41659df318c8198ea7f428
| * | [tests] util_tests.cpp: actually check ignored argsAnthony Towns2018-01-041-1/+1
| | | | | | | | | | | | | | | | | | An array with 7 elements was setup for checking argument parsing, but was passed to ParseParamaeters with argc=5, meaning the interpretation of the last two arguments was never actually checked.
* | | Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|/ /
* | scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* | Allow setting nMinimumChainWork on command lineSuhas Daftuar2017-09-051-0/+25
| |
* | scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift2017-08-071-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
* | scripted-diff: Use new naming style for insecure_rand* functionsPieter Wuille2017-06-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/\<insecure_randbits(/InsecureRandBits(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randbool(/InsecureRandBool(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randrange(/InsecureRandRange(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_randbytes(/InsecureRandBytes(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_rand256(/InsecureRand256(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<insecure_rand(/InsecureRand32(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp sed -i 's/\<seed_insecure_rand(/SeedInsecureRand(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp -END VERIFY SCRIPT-
* | Merge test_random.h into test_bitcoin.hPieter Wuille2017-06-051-1/+0
| |
* | Util: Create ArgsManager class...Jorge Timón2017-05-091-32/+45
| | | | | | | | | | - Introduce ArgsManager::GetArgs() - Adapt util_tests.cpp to ArgsManager
* | [trivial] Fix typos in commentspracticalswift2017-03-211-1/+1
| |
* | Fix msvc compiler error C4146 (unary minus operator applied to unsigned type)kobake2017-03-081-1/+1
| | | | | | | | | | On msvc14, int literal '-2147483648' is invalid, because '2147483648' is unsigned type and cant't apply minus operator to unsigned type. To define the int literal correctly, use '-2147483647 - 1' formula that is also used to define INT_MIN in limits.h.
* | Merge #9281: Refactor: Remove using namespace <xxx> from bench/ & test/ sourcesMarcoFalke2017-01-051-3/+1
|\ \ | | | | | | | | | 73f4119 Refactoring: Removed using namespace <xxx> from bench/ and test/ source files. (Karl-Johan Alm)
| * | Refactoring: Removed using namespace <xxx> from bench/ and test/ source files.Karl-Johan Alm2017-01-021-3/+1
| | |
* | | Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
|/ / | | | | | | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* | Un-expose mapArgs from utils.hMatt Corallo2016-12-241-0/+2
| |
* | Introduce (and use) an IsArgSet accessor methodMatt Corallo2016-12-231-2/+2
| |