aboutsummaryrefslogtreecommitdiff
path: root/src/test/coins_tests.cpp
AgeCommit message (Collapse)Author
2017-01-04Check FRESH validity in CCoinsViewCache::BatchWriteRussell Yanofsky
2017-01-04Merge #9107: Safer modify new coinsPieter Wuille
b50cd7a Fix dangerous condition in ModifyNewCoins. (Alex Morcos)
2017-01-04Fix dangerous condition in ModifyNewCoins.Alex Morcos
We were marking coins FRESH before being sure they were not overwriting dirty undo data. This condition was never reached in existing code because undo data was always flushed before UpdateCoins was called with new transactions, but could have been exposed in an otherwise safe refactor. Clarify in the comments the assumptions made in ModifyNewCoins. Add ability to undo transactions to UpdateCoins unit test. Thanks to Russ Yanofsky for suggestion on how to make logic clearer and fixing up the ccoins_modify_new test cases.
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-12-27Remove unused variable in test, fixing warning.Russell Yanofsky
Pointed out by Pavel Janík <Pavel@Janik.cz> in https://github.com/bitcoin/bitcoin/pull/9308.
2016-12-05[test] Add CCoinsViewCache Access/Modify/Write testsRussell Yanofsky
Add more comprehensive unit tests for CCoinsViewCache. Right now it is hard to refactor caching code or fix bugs in the caching logic because you have to try to mentally enumerate all the different states the cache might be in to make sure a change doesn't cause unintended consequences. The new tests explicitly enumerate relevant cache states, documenting and verifying the behavior in each state, so it will be safer and easier to make changes to the caching code in the future.
2016-12-02Rename the remaining main.{h,cpp} to validation.{h,cpp}Matt Corallo
2016-11-07test: Fix test_random includesMarcoFalke
2016-10-17Kill insecure_random and associated global stateWladimir J. van der Laan
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`.
2016-04-30Remove obsolete reference to CValidationState from UpdateCoins.21E14
2016-04-25Add tests for CCoins deserializationPieter Wuille
2016-04-15txdb: Add Cursor() method to CCoinsView to iterate over UTXO setWladimir J. van der Laan
Add a method Cursor() to CCoinsView that returns a cursor which can be used to iterate over the whole UTXO set. - rpc: Change gettxoutsetinfo to use new Cursor method - txdb: Remove GetStats method - Now that GetStats is implemented in terms of Cursor, remove it.
2015-12-13Bump copyright headers to 2015MarcoFalke
2015-11-18Alter assumptions in CCoinsViewCache::BatchWriteAlex Morcos
Previously it would break if you flushed a parent cache while there was a child cache referring to it. This change will allow the flushing of parent caches.
2015-11-12Add unit test for UpdateCoinsAlex Morcos
2015-11-11Make CCoinsViewTest behave like CCoinsViewDBAlex Morcos
2015-07-20Separate core memory usage computation in core_memusage.hPieter Wuille
2015-05-11Keep track of memory usage in CCoinsViewCachePieter Wuille
2015-03-12tests: add a BasicTestingSetup and apply to all testsWladimir J. van der Laan
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.
2014-09-24Get rid of the dummy CCoinsViewCache constructor argPieter Wuille
2014-09-23Add coins_tests with a large randomized CCoinViewCache test.Pieter Wuille