aboutsummaryrefslogtreecommitdiff
path: root/src/test/util/chainstate.h
AgeCommit message (Collapse)Author
2024-03-18assumeutxo: Get rid of faked nTx and nChainTx valuesRyan Ofsky
The `PopulateAndValidateSnapshot` function introduced in f6e2da5fb7c6406c37612c838c998078ea8d2252 from #19806 has been setting fake `nTx` and `nChainTx` values that can show up in RPC results (see #29328) and make `CBlockIndex` state hard to reason about, because it is difficult to know whether the values are real or fake. Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the values are unknown, instead of faking them. This commit fixes at least two assert failures in the (pindex->nChainTx == pindex->nTx + prev_chain_tx) check that would happen previously. Tests for these failures are added separately in the next two commits. Compatibility note: This change could result in -checkblockindex failures if a snapshot was loaded by a previous version of Bitcoin Core and not fully validated, because fake nTx values will have been saved to the block index. It would be pretty easy to avoid these failures by adding some compatibility code to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake (when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a little simpler not to worry about being compatible in this case.
2023-09-30validation: do not activate snapshot if behind active chainJames O'Beirne
Most easily reviewed with git show --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2023-08-03refactor: fix unterminated LogPrintf()sfanquake
2023-07-14test: Clear block index flags when testing snapshotsSuhas Daftuar
When simulating a snapshot, remove the HAVE_DATA status for blocks below the snapshot height, to simulate never having downloaded them at all. This makes tests more realistic (and more closely match what will happen when using assumeutxo).
2023-03-23refactor: Move fs.* to util/fs.*TheCharlatan
The fs.* files are already part of the libbitcoin_util library. With the introduction of the fs_helpers.* it makes sense to move fs.* into the util/ directory as well.
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-09-13test: allow on-disk coins and block tree dbs in testsJames O'Beirne
Used when testing cleanup of on-disk chainstate data for snapshot testcases. Also necessary for simulating node restart in .cpp tests.
2022-09-13test: add reset_chainstate parameter for snapshot unittestsJames O'Beirne
This CreateAndActivateUTXOSnapshot parameter is necessary once we perform snapshot completion within ABC, since the existing UpdateTip test will fail because the IBD chain that has generated the snapshot will exceed the base of the snapshot. Being able to test snapshots being loaded into a mostly-uninitialized datadir allows for more realistic unittest scenarios.
2022-09-05test: remove Boost Test from libtest utilfanquake
Context is the discussion here: https://github.com/bitcoin/bitcoin/pull/25974/files#r961541457.
2022-06-29Use AutoFile where possibleMacroFake
2022-04-21Disallow more unsafe string->path conversions allowed by path append operatorsRyan Ofsky
Add more fs::path operator/ and operator+ overloads to prevent unsafe string->path conversions on Windows that would cause strings to be decoded according to the current Windows locale & code page instead of the correct string encoding. Update application code to deal with loss of implicit string->path conversions by calling fs::u8path or fs::PathFromString explicitly, or by just changing variable types from std::string to fs::path to avoid conversions altoghther, or make them happen earlier. In all cases, there's no change in behavior either (1) because strings only contained ASCII characters and would be decoded the same regardless of what encoding was used, or (2) because of the 1:1 mapping between paths and strings using the PathToString and PathFromString functions. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-01-06Add src/node/* code to node:: namespaceRussell Yanofsky
2021-12-02Merge bitcoin/bitcoin#23155: rpc: various fixups for dumptxoutsetW. J. van der Laan
ffd09281fe26446fcefa0627c220a52706e35227 rpc: various fixups for dumptxoutset (James O'Beirne) Pull request description: This is part of the [assumeutxo project](https://github.com/bitcoin/bitcoin/projects/11) (parent PR: #15606) --- A few fixes to make this RPC actually useful when generating snapshots. - Generate an assumeutxo hash and display it (sort of a bugfix) - Add nchaintx to output (necessary for use in chainparams entry) - Add path of serialized UTXO file to output ACKs for top commit: laanwj: Code review ACK ffd09281fe26446fcefa0627c220a52706e35227 Tree-SHA512: b0b5fd5138dea0e21258b1b18ab75bf3fd1628522cc1dbafa81af9cb9fa96562a1c39124fdb31057f256bfc560f462f907e9fe5e209b577b3f57afae2b7be826
2021-11-30rpc: various fixups for dumptxoutsetJames O'Beirne
- Actually generate an assumeutxo hash and display it - Add nchaintx to output (necessary for use in chainparams entry) - Add path of serialized UTXO file to output
2021-11-19scripted-diff: Use clang-tidy syntax for C++ named argumentsMarcoFalke
-BEGIN VERIFY SCRIPT- perl -0777 -pi -e 's:((\(|\{|,)(\n| )*)\/\* ?([^=* ]+) ?\*\/ ?:\1/*\4=*/:g' $( git ls-files ./src/test ./src/wallet/test ) -END VERIFY SCRIPT-
2021-10-05refactor: Block unsafe fs::path std::string conversion callsRussell Yanofsky
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding calls to methods which will be unsafe after the transaction to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Kiminuo <kiminuo@protonmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2021-09-15test: refactor: declare NoMalleation const autoJames O'Beirne
To avoid linker error on some platforms: https://github.com/bitcoin/bitcoin/pull/21526#discussion_r709404714 Co-authored-by: Russ Yanofsky <russ@yanofsky.org>
2021-09-15move-only: unittest: add test/util/chainstate.hJames O'Beirne
and move `CreateAndActivateUTXOSnapshot()` into it for reuse in future test modules.