elements/src/wallet/test
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
..
fuzz coin selection: BnB, don't return selection if exceeds max allowed tx weight 2023-04-05 09:32:39 -03:00
coinselector_tests.cpp scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB 2023-05-03 10:45:10 -04:00
db_tests.cpp refactor: Move fs.* to util/fs.* 2023-03-23 12:55:18 +01:00
feebumper_tests.cpp test: Remove unused txmempool include from tests 2022-10-18 14:02:09 +02:00
group_outputs_tests.cpp scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB 2023-05-03 10:45:10 -04:00
init_test_fixture.cpp refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
init_test_fixture.h refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
init_tests.cpp move-only: Extract common/args and common/config.cpp from util/system 2023-04-19 10:48:30 +02:00
ismine_tests.cpp wallet, tests: Replace usage of dummy db with mockable db 2023-05-03 10:45:10 -04:00
psbt_wallet_tests.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
rpc_util_tests.cpp refactor: move Boost datetime usage to wallet 2022-10-01 11:41:53 +01:00
scriptpubkeyman_tests.cpp wallet, tests: Replace usage of dummy db with mockable db 2023-05-03 10:45:10 -04:00
spend_tests.cpp refactor: wallet, remove global 'ArgsManager' access 2023-02-15 15:49:45 -03:00
util.cpp tests: Update DuplicateMockDatabase for MockableDatabase 2023-05-03 10:45:10 -04:00
util.h tests: Update DuplicateMockDatabase for MockableDatabase 2023-05-03 10:45:10 -04:00
wallet_crypto_tests.cpp Move random test util code from setup_common to random 2023-02-06 12:26:04 -08:00
wallet_test_fixture.cpp Merge bitcoin/bitcoin#26715: Introduce MockableDatabase for wallet unit tests 2023-05-15 11:39:43 +01:00
wallet_test_fixture.h refactor: Replace string chain name constants with ChainTypes 2023-05-09 15:49:14 +02:00
wallet_tests.cpp Merge bitcoin/bitcoin#26715: Introduce MockableDatabase for wallet unit tests 2023-05-15 11:39:43 +01:00
wallet_transaction_tests.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
walletdb_tests.cpp scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
walletload_tests.cpp tests: Modify records directly in wallet ckey loading test 2023-05-03 10:45:10 -04:00