Skip to content

Conversation

@vijaydasmp
Copy link

Backports

@vijaydasmp vijaydasmp changed the title Backport: Merge bitcoin/bitcoin#26715 backport: Merge bitcoin#26715 Dec 3, 2025
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@vijaydasmp vijaydasmp force-pushed the Dec_2025_2 branch 4 times, most recently from abc0fb4 to 18f9e27 Compare December 4, 2025 07:35
33e2b82 wallet, bench: Remove unused database options from WalletBenchLoading (Andrew Chow)
80ace04 tests: Modify records directly in wallet ckey loading test (Andrew Chow)
b3bb17d tests: Update DuplicateMockDatabase for MockableDatabase (Andrew Chow)
f0eecf5 scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB (Andrew Chow)
075962b wallet, tests: Include wallet/test/util.h (Andrew Chow)
14aa4cb wallet: Move DummyDatabase to salvage (Andrew Chow)
f67a385 wallet, tests: Replace usage of dummy db with mockable db (Andrew Chow)
33c6245 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 bitcoin#26644

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

Tree-SHA512: c2b09eff9728d063d2d4aea28a0f0e64e40b76483e75dc53f08667df23bd25834d52656cd4eafb02e552db0b9e619cfdb1b1c65b26b5436ee2c971d804768bcc
0282b21 walletdb: Remove unused CreateMockWalletDatabase (Andrew Chow)

Pull request description:

  This has been superseded by the MockableDatabase. Remove to avoid confusion as to which type of mock database to use for testing.

  I thought this was included in bitcoin#26715, maybe it got lost in a rebase.

ACKs for top commit:
  furszy:
    utACK 0282b21
  brunoerg:
    crACK 0282b21

Tree-SHA512: 18445c4d8a4e2609ef7471c6d75297f43694b79e768f6c993a5addb1dc0e88bd12bac263c9d8e903d828ddf6bf50434f9e2f72048f4fc528e98fed8ee65123ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants