aboutsummaryrefslogtreecommitdiff
path: root/src/test/validation_chainstatemanager_tests.cpp
AgeCommit message (Collapse)Author
2021-06-13refactor: Remove chainparams arg from CChainState member functionsMarcoFalke
Passing this is confusing and redundant with the m_params member.
2021-05-11refactor: Avoid magic value of all-zeros in assumeutxo base_blockhashMarcoFalke
Just use std::optional
2021-05-11Fix assumeutxo crash due to invalid base_blockhashMarcoFalke
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2021-04-26validation: remove nchaintx from assumeutxo metadataJames O'Beirne
This value is no longer used and is instead specified statically in chainparams. This change means that previously generated snapshots will no longer be usable.
2021-04-14validation: fix ActivateSnapshot to use hardcoded nChainTxJames O'Beirne
This fixes an oversight from the move of nChainTx from the user-supplied snapshot metadata into the hardcoded assumeutxo chainparams. Since the nChainTx is now unused in the metadata, it should be removed in a future commit.
2021-04-08test: Remove option to make TestChain100Setup non-deterministicMarcoFalke
Seems odd to have an option for non-deterministic tests when the goal should be for all tests to be deterministic. Can be reviewed with `--ignore-all-space`.
2021-04-04Fix assumeutxo crash due to missing base_blockhashMarcoFalke
2021-02-12test: Add tests with maleated snapshot dataFabian Jahr
2021-02-12tests: add snapshot activation testJames O'Beirne
2021-02-12simplify ChainstateManager::SnapshotBlockhash() return semanticsJames O'Beirne
Don't return null snapshotblockhash values to avoid caller complexity/confusion.
2021-01-12Merge #20495: sync: Use decltype(auto) return type for WITH_LOCKfanquake
3eb94ec81b72b14f72a1f6ce5c9aa24476df755a sync: Use decltype(auto) return type for WITH_LOCK (Carl Dong) Pull request description: > Now that we're using C++17, we can use the decltype(auto) return type > for functions and lambda expressions. > > As demonstrated in this commit, this can simplify cases where previously > the compiler failed to deduce the correct return type. > > Just for reference, for the "assign to ref" cases fixed here, there are > 3 possible solutions: > > - Return a pointer and immediately deref as used before this commit > - Make sure the function/lambda returns declspec(auto) as used after > this commit > - Class& i = WITH_LOCK(..., return std::ref(...)); > > ----- > > References: > 1. https://en.cppreference.com/w/cpp/language/function#Return_type_deduction > 2. https://en.cppreference.com/w/cpp/language/template_argument_deduction#Other_contexts > 3. https://en.cppreference.com/w/cpp/language/auto > 4. https://en.cppreference.com/w/cpp/language/decltype > > Explanations: > 1. https://stackoverflow.com/a/21369192 > 2. https://stackoverflow.com/a/21369170 Thanks to sipa and ryanofsky for helping me understand this ACKs for top commit: jnewbery: utACK 3eb94ec81b72b14f72a1f6ce5c9aa24476df755a hebasto: ACK 3eb94ec81b72b14f72a1f6ce5c9aa24476df755a, I have reviewed the code and it looks OK, I agree it can be merged. I have verified possible warnings: ryanofsky: Code review ACK 3eb94ec81b72b14f72a1f6ce5c9aa24476df755a Tree-SHA512: 5f55c7722aeca8ea70e5c1a8db93e93ba0e356e8967e7f607ada38003df4b153d73c29bd2cea8d7ec1344720d37d857ea7dbfd2a88da1d92e0e9cbb9abd287df
2020-12-08test: Add new ChainTestingSetup and use itCarl Dong
Previously, the validation_chainstatemanager_tests test suite instantiated its own duplicate ChainstateManager on which tests were performed. This wasn't a problem for the specific actions performed in that suite. However, the existence of this duplicate ChainstateManager and the fact that many of our validation static functions reach for g_chainman, ::Chain(state|)Active means we may end up acting on two different CChainStates should we write more extensive tests in the future. This change adds a new ChainTestingSetup which performs all initialization previously done by TestingSetup except: 1. RPC command registration 2. ChainState initialization 3. Genesis Activation 4. {Ban,Conn,Peer}Man initialization Means that we will no longer need to initialize a duplicate ChainstateManger in order to test the initialization codepaths of CChainState and ChainstateManager. Lastly, this change has the additional benefit of allowing for review-only assertions meant to show correctness to work in future work de-globalizing g_chainman. In the test chainstatemanager_rebalance_caches, an additional LoadGenesisBlock call is added as MaybeReblanaceCaches eventually calls FlushBlockFile, which tries to access vinfoBlockFile[nLastBlockFile], which is out of bounds when LoadGenesisBlock hasn't been called yet. ----- Note for the future: The class con/destructor inheritance structure we have for these TestingSetup classes is probably not the most suitable abstraction. In particular, for both TestingSetup and ChainTestingSetup, we need to stop the scheduler first before anything else. Otherwise classes depending on the scheduler may be referenced by the scheduler after said classes are freed. This means that there's no clear parallel between our teardown code and C++'s destructuring order for class hierarchies. Future work should strive to coalesce (as much as possible) test and non-test init codepaths and perhaps structure it in a more fail-proof way.
2020-12-04sync: Use decltype(auto) return type for WITH_LOCKCarl Dong
Now that we're using C++17, we can use the decltype(auto) return type (available since C++14) for functions and lambda expressions. As demonstrated in this commit, this can simplify cases where previously the compiler failed to deduce the correct return type. Just for reference, for the "assign to ref" cases fixed here, there are 3 possible solutions: - Return a pointer and immediately deref as used before this commit - Make sure the function/lambda returns declspec(auto) as used after this commit - Class& i = WITH_LOCK(..., return std::ref(...)); ----- References: 1. https://en.cppreference.com/w/cpp/language/function#Return_type_deduction 2. https://en.cppreference.com/w/cpp/language/template_argument_deduction#Other_contexts 3. https://en.cppreference.com/w/cpp/language/auto 4. https://en.cppreference.com/w/cpp/language/decltype Explanations: 1. https://stackoverflow.com/a/21369192 2. https://stackoverflow.com/a/21369170 3. Item 3 in Effective Modern C++ (Scott Meyers) via jnewbery
2020-08-28Pass mempool reference to chainstate constructorMarcoFalke
2020-07-29test: Simplify cs_main locksMarcoFalke
2020-07-01add ChainstateManager::MaybeRebalanceCaches()James O'Beirne
Aside from in unittests, this method is unused at the moment. It will be used in upcoming commits that enable utxo snapshot activation.
2020-07-01Add CChainState::ResizeCoinsCachesJames O'Beirne
Also adds CCoinsViewCache::ReallocateCache() to attempt to free memory that the cacheCoins's allocator may be hanging onto when downsizing the cache. Adds `CChainState::m_coins{tip,db}_cache_size_bytes` data members so that we can reference cache size on a per-chainstate basis for flushing.
2020-04-16scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-04-15test: Avoid accessing free'd memory in validation_chainstatemanager_testsMarcoFalke
2020-03-17test: add basic tests for ChainstateManagerJames O'Beirne
Feedback incorporated from Russell Yanofsky. Co-authored-by: MarcoFalke <falke.marco@gmail.com>