aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Fix non-const mapMultiArgs[] access after init.Matt Corallo2016-12-231-1/+1
| | | | | Swap mapMultiArgs for a const-reference to a _mapMultiArgs which is only accessed in util.cpp
* test: Fix test_random includesMarcoFalke2016-11-071-1/+1
|
* Kill insecure_random and associated global stateWladimir J. van der Laan2016-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are only a few uses of `insecure_random` outside the tests. This PR replaces uses of insecure_random (and its accompanying global state) in the core code with an FastRandomContext that is automatically seeded on creation. This is meant to be used for inner loops. The FastRandomContext can be in the outer scope, or the class itself, then rand32() is used inside the loop. Useful e.g. for pushing addresses in CNode or the fee rounding, or randomization for coin selection. As a context is created per purpose, thus it gets rid of cross-thread unprotected shared usage of a single set of globals, this should also get rid of the potential race conditions. - I'd say TxMempool::check is not called enough to warrant using a special fast random context, this is switched to GetRand() (open for discussion...) - The use of `insecure_rand` in ConnectThroughProxy has been replaced by an atomic integer counter. The only goal here is to have a different credentials pair for each connection to go on a different Tor circuit, it does not need to be random nor unpredictable. - To avoid having a FastRandomContext on every CNode, the context is passed into PushAddress as appropriate. There remains an insecure_random for test usage in `test_random.h`.
* [test] Remove unused codeMarcoFalke2016-08-241-7/+2
|
* util: Add ParseUInt32 and ParseUInt64Wladimir J. van der Laan2016-06-081-0/+63
| | | | | | | | | | Add error and range-checking parsers for unsigned 32 and 64 bit numbers. The 32-bit variant is required for parsing sequence numbers from the command line in `bitcoin-tx` (see #8164 for discussion). I've thrown in the 64-bit variant as a bonus, as I'm sure it will be needed at some point. Also adds tests, and updates `developer-notes.md`.
* [tests] Extend util_ParseMoney test caseMarcoFalke2016-03-141-0/+5
|
* test: test leading space for ParseHexWladimir J. van der Laan2016-02-151-0/+4
| | | | | | BerkeleyDB dump files have key and value lines indented. The salvage code passes these to ParseHex as-is. Check this in the tests (should just pass with current code).
* Merge branch 'master' into single_prodnameLuke Dashjr2016-02-031-1/+1
|\
| * Bump copyright headers to 2015MarcoFalke2015-12-131-1/+1
| |
* | Rewrite FormatParagraph to handle newlines within input strings correctlyLuke Dashjr2016-02-031-3/+18
|/
* SanitizeString: Allow hypen charMarcoFalke2015-09-231-2/+2
|
* [uacomment] Sanitize per BIP-0014MarcoFalke2015-09-161-2/+2
| | | | | | * SanitizeString() can be requested to be more strict * Throw error when SanitizeString() changes uacomments * Fix tests
* rpc: Accept scientific notation for monetary amounts in JSONWladimir J. van der Laan2015-07-101-0/+66
| | | | | | | | | | | Add a function `ParseFixedPoint` that parses numbers according to the JSON number specification and returns a 64-bit integer. Then this in `AmountFromValue`, rather than `ParseMoney`. Also add lots of tests (thanks to @jonasschnelli for some of them). Fixes issue #6297.
* Merge pull request #6239Wladimir J. van der Laan2015-06-091-23/+21
|\ | | | | | | | | | | 7d8ffac Changes necessary now that zero values accepted in AmountFromValue (Wladimir J. van der Laan) a04bdef Get rid of fPlus argument to FormatMoney (Wladimir J. van der Laan) 4b4b9a8 Don't go through double in AmountFromValue and ValueFromAmount (Wladimir J. van der Laan)
| * Get rid of fPlus argument to FormatMoneyWladimir J. van der Laan2015-06-061-23/+21
| | | | | | | | It's never used with any other value than false, the default.
* | fix util_tests.cpp clang warningsJonas Schnelli2015-06-061-2/+2
|/ | | | was introduced with #6121
* util: Add ParseInt64 and ParseDouble functionsWladimir J. van der Laan2015-06-041-0/+65
| | | | | | | | | | | Strict parsing functions for other numeric types. - ParseInt64 analogous to ParseInt32, but for 64-bit values. - ParseDouble for doubles. - Make all three Parse* functions more strict (e.g. reject whitespace on the inside) Also add tests.
* tests: add a BasicTestingSetup and apply to all testsWladimir J. van der Laan2015-03-121-1/+2
| | | | | | | | Make sure that chainparams and logging is properly initialized. Doing this for every test may be overkill, but this initialization is so simple that that does not matter. This should fix the travis issues.
* c++11: These look like user-defined literals.Cory Fields2015-02-031-9/+9
| | | | Add a space to keep the compiler happy
* Remove references to X11 licenceMichael Ford2014-12-161-1/+1
|
* Add a new test for FormatParagraph (string longer than the default width).Pavel Janík2014-12-061-0/+1
|
* MOVEONLY: core/ -> primitives/Luke Dashjr2014-12-031-1/+1
|
* Separate protocol versioning from clientversionCory Fields2014-10-291-1/+1
|
* MOVEONLY: Separate CTransaction and dependencies from corejtimon2014-10-271-1/+1
|
* boost: drop boost dependency in version.cpp.Cory Fields2014-10-151-0/+12
| | | | Also add a test to verify.
* Use a typedef for monetary valuesMark Friedenbach2014-09-261-1/+1
|
* Split up util.cpp/hWladimir J. van der Laan2014-08-261-0/+3
| | | | | | | | | | | | | | | | Split up util.cpp/h into: - string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach) - money utilities (parsesmoney, formatmoney) - time utilities (gettime*, sleep, format date): - and the rest (logging, argument parsing, config file parsing) The latter is basically the environment and OS handling, and is stripped of all utility functions, so we may want to rename it to something else than util.cpp/h for clarity (Matt suggested osinterface). Breaks dependency of sha256.cpp on all the things pulled in by util.
* Move CMedianFilter to timedata.cppWladimir J. van der Laan2014-08-261-25/+0
| | | | | Now that we no longer use the median filter to keep track of the number of blocks of peers, that's the only place it is used.
* move rand functions from util to new random.h/.cppPhilip Kaufmann2014-07-091-0/+1
|
* util: Add function FormatParagraph to format paragraph to fixed-widthWladimir J. van der Laan2014-06-111-0/+11
| | | | This is to be used for the `-version` and `-help` messages.
* Replace non-threadsafe gmtime and setlocaleWladimir J. van der Laan2014-05-231-3/+1
| | | | | | | Make DateTimeStrFormat use boost::posix_time. Also re-enable the util_DateTimeStrFormat tests, as they are no longer platform specific.
* Merge pull request #4138Wladimir J. van der Laan2014-05-121-6/+6
|\ | | | | | | 783b182 Remove dummy PRIszX macros for formatting (Wladimir J. van der Laan)
| * Remove dummy PRIszX macros for formattingWladimir J. van der Laan2014-05-061-6/+6
| | | | | | | | | | | | | | | | | | Size specifiers are no longer needed now that we use typesafe tinyformat for string formatting, instead of the system's sprintf. No functional changes. This continues the work in #3735.
* | Remove unused function WildcardMatchWladimir J. van der Laan2014-05-091-11/+0
| | | | | | | | | | No longer necessary after implementing netmask-based matching. Also remove a longer-unused function `skipspaces`.
* | util: add parseint32 function with strict error reportingWladimir J. van der Laan2014-05-091-0/+22
|/ | | | | | None of the current integer parsing functions in util check whether the result is valid and fits in the range of the type. This is required for less sloppy error reporting.
* Add licenses for tests and test dataWladimir J. van der Laan2014-03-181-0/+4
| | | | | | | | - Add license headers to source files (years based on commit dates) in `src/test` as well as `qa` - Add `README.md` to `src/test/data` specifying MIT license Fixes #3848
* Get rid of C99 PRI?64 usage in source filesWladimir J. van der Laan2014-02-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Amend to d5f1e72. It turns out that BerkelyDB was including inttypes.h indirectly, so we cannot fix this with just macros. Trivial commit: apply the following script to all .cpp and .h files: # Middle sed -i 's/"PRIx64"/x/g' "$1" sed -i 's/"PRIu64"/u/g' "$1" sed -i 's/"PRId64"/d/g' "$1" # Initial sed -i 's/PRIx64"/"x/g' "$1" sed -i 's/PRIu64"/"u/g' "$1" sed -i 's/PRId64"/"d/g' "$1" # Trailing sed -i 's/"PRIx64/x"/g' "$1" sed -i 's/"PRIu64/u"/g' "$1" sed -i 's/"PRId64/d"/g' "$1" After this commit, `git grep` for PRI.64 should turn up nothing except the defines in util.h.
* Add test for GetTime()Wladimir J. van der Laan2014-01-091-0/+8
| | | | | Test for mingw/wine issue #3494, where the upper word of time(NULL) return value gets clobbered.
* tests: add testcases for strprintfWladimir J. van der Laan2013-11-131-0/+27
|
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-6/+7
| | | | | | | | | Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
* Make RPC password resistant to timing attacksGavin Andresen2013-08-081-0/+11
| | | | | | | Fixes issue#2838; this is a tweaked version of pull#2845 that should not leak the length of the password and is more generic, in case we run into other situations where we need timing-attack-resistant comparisons.
* Make the rand tests determinstic. (fixes #2714)Gregory Maxwell2013-07-071-33/+1
| | | | | | This avoids spurious errors with the old tests but still tests enough that if the rng is replaced with a totally broken one it should still fail.
* remove GetBoolArg() fDefault parameter defaulting to falsePhilip Kaufmann2013-06-011-12/+12
| | | | | | | | - explicitly set the default of all GetBoolArg() calls - rework getarg_test.cpp and util_tests.cpp to cover this change - some indentation fixes - move macdockiconhandler.h include in bitcoin.cpp to the "our headers" section
* Remove flaky util thread unit testsGavin Andresen2013-05-031-58/+0
|
* LoopForever and ThreadTrace helpersGavin Andresen2013-04-031-0/+58
|