0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/bench
fanquake d02df7db6b
Merge bitcoin/bitcoin#26715: Introduce MockableDatabase for wallet unit tests
33e2b82a4f wallet, bench: Remove unused database options from WalletBenchLoading (Andrew Chow)
80ace042d8 tests: Modify records directly in wallet ckey loading test (Andrew Chow)
b3bb17d5d0 tests: Update DuplicateMockDatabase for MockableDatabase (Andrew Chow)
f0eecf5e40 scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB (Andrew Chow)
075962bc25 wallet, tests: Include wallet/test/util.h (Andrew Chow)
14aa4cb1e4 wallet: Move DummyDatabase to salvage (Andrew Chow)
f67a385556 wallet, tests: Replace usage of dummy db with mockable db (Andrew Chow)
33c6245ac1 Introduce MockableDatabase for wallet unit tests (Andrew Chow)

Pull request description:

  For the wallet's unit tests, we currently use either `DummyDatabase` or memory-only versions of either BDB or SQLite. The tests that use `DummyDatabase` just need a `WalletDatabase` so that the `CWallet` can be constructed, while the tests using the memory-only databases just need a backing data store. There is also a `FailDatabase` that is similar to `DummyDatabase` except it fails be default or can have a configured return value. Having all of these different database types can make it difficult to write tests, particularly tests that work when either BDB or SQLite is disabled.

  This PR unifies all of these different unit test database classes into a single `MockableDatabase`. Like `DummyDatabase`, most functions do nothing and just return true. Like `FailDatabase`, the return value of some functions can be configured on the fly to test various failure cases. Like the memory-only databases, records can actually be written to the `MockableDatabase` and be retrieved later, but all of this is still held in memory. Using `MockableDatabase` completely removes the need for having BDB or SQLite backed wallets in the unit tests for the tests that are not actually testing specific database behaviors.

  Because `MockableDatabase`s can be created by each unit test, we can also control what records are stored in the database. Records can be added and removed externally from the typical database modification functions. This will give us greater ability to test failure conditions, particularly those involving corrupted records.

  Possible alternative to #26644

ACKs for top commit:
  furszy:
    ACK 33e2b82
  TheCharlatan:
    ACK 33e2b82a4f

Tree-SHA512: c2b09eff9728d063d2d4aea28a0f0e64e40b76483e75dc53f08667df23bd25834d52656cd4eafb02e552db0b9e619cfdb1b1c65b26b5436ee2c971d804768bcc
2023-05-15 11:39:43 +01:00
..
data Add deserialize + CheckBlock benchmarks, and a full block hex 2016-11-09 11:27:59 -08:00
.gitignore Ignore bench_bitcoin binary. 2015-10-06 17:46:12 +02:00
addrman.cpp bench: test select for a new table with only one address 2023-03-17 18:02:40 -07:00
base58.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
bech32.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
bench.cpp refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
bench.h refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
bench_bitcoin.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
block_assemble.cpp test: Add util to mine invalid blocks 2023-05-02 17:17:06 +02:00
ccoins_caching.cpp Merge bitcoin/bitcoin#26691: Update secp256k1 subtree to libsecp256k1 version 0.2.0 2023-01-13 09:40:57 +00:00
chacha20.cpp Only support 32-byte keys in ChaCha20{,Aligned} 2023-01-30 18:12:21 -05:00
chacha_poly_aead.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
checkblock.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
checkqueue.cpp refactor: Use move semantics in CCheckQueue::Loop 2023-03-21 13:04:21 +00:00
coin_selection.cpp wallet, tests: Replace usage of dummy db with mockable db 2023-05-03 10:45:10 -04:00
crypto_hash.cpp Merge bitcoin/bitcoin#15294: refactor: Extract RipeMd160 2023-01-30 09:49:01 +01:00
data.cpp scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
data.h bench: Move generated data to a dedicated translation unit 2019-07-02 18:11:15 +01:00
descriptors.cpp Merge bitcoin/bitcoin#26691: Update secp256k1 subtree to libsecp256k1 version 0.2.0 2023-01-13 09:40:57 +00:00
duplicate_inputs.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
examples.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
gcs_filter.cpp Fix clang-tidy readability-const-return-type violations 2023-02-01 11:33:35 +01:00
hashpadding.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
load_external.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
lockedpool.cpp clang-tidy: Add performance-inefficient-vector-operation check 2023-03-26 20:17:55 +01:00
logging.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
mempool_eviction.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
mempool_stress.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
merkle_root.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
nanobench.cpp Replace current benchmarking framework with nanobench 2020-06-13 12:24:18 +02:00
nanobench.h Update nanobench to version v4.3.10 2023-02-03 07:08:28 +01:00
peer_eviction.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
poly1305.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
pool.cpp Add pool based memory resource & allocator 2023-03-23 19:38:38 +01:00
prevector.cpp Use DataStream where possible 2023-01-26 10:44:05 +01:00
rollingbloom.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
rpc_blockchain.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
rpc_mempool.cpp scripted-diff: Remove unused chainparamsbase includes 2023-05-09 15:49:19 +02:00
streams_findbyte.cpp util: improve streams.h:FindByte() performance 2023-05-05 06:03:17 -06:00
strencodings.cpp bench: explicitly make all current benchmarks "high" priority 2022-10-20 10:21:04 -03:00
util_time.cpp refactor: Remove unused GetTimeMillis 2023-05-08 12:40:48 +02:00
verify_script.cpp Merge bitcoin/bitcoin#26691: Update secp256k1 subtree to libsecp256k1 version 0.2.0 2023-01-13 09:40:57 +00:00
wallet_balance.cpp scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB 2023-05-03 10:45:10 -04:00
wallet_create_tx.cpp scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB 2023-05-03 10:45:10 -04:00
wallet_loading.cpp wallet, bench: Remove unused database options from WalletBenchLoading 2023-05-03 11:05:56 -04:00