Skip to content

Commit 8456bfa

Browse files
committed
Merge bitcoin/bitcoin#26638: test: prefer sqlite for wallet tests
17554ef test: prefer sqlite for wallet tests (S3RK) 8e0faba test: make wallet_migration.py pass with both wallet flags (S3RK) Pull request description: Fixes #26511 ACKs for top commit: MarcoFalke: review ACK 17554ef achow101: ACK 17554ef Tree-SHA512: 97cae275998f07032feffe1b533d4747b8ff03c3c1fb830af69ee38cadb75fd58532956f66f79c0d275b00620ce53b0b5240f885e4f29b8bd4d0b6e6cbc683fa
2 parents cbcad79 + 17554ef commit 8456bfa

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ def parse_args(self):
214214
self.options.descriptors = None
215215
elif self.options.descriptors is None:
216216
# Some wallet is either required or optionally used by the test.
217-
# Prefer BDB unless it isn't available
218-
if self.is_bdb_compiled():
219-
self.options.descriptors = False
220-
elif self.is_sqlite_compiled():
217+
# Prefer SQLite unless it isn't available
218+
if self.is_sqlite_compiled():
221219
self.options.descriptors = True
220+
elif self.is_bdb_compiled():
221+
self.options.descriptors = False
222222
else:
223223
# If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
224224
# It still needs to exist and be None in order for tests to work however.

test/functional/wallet_migration.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ def assert_is_sqlite(self, wallet_name):
4040
assert_equal(file_magic, b'SQLite format 3\x00')
4141
assert_equal(self.nodes[0].get_wallet_rpc(wallet_name).getwalletinfo()["format"], "sqlite")
4242

43-
def create_legacy_wallet(self, wallet_name):
44-
self.nodes[0].createwallet(wallet_name=wallet_name)
43+
def create_legacy_wallet(self, wallet_name, disable_private_keys=False):
44+
self.nodes[0].createwallet(wallet_name=wallet_name, descriptors=False, disable_private_keys=disable_private_keys)
4545
wallet = self.nodes[0].get_wallet_rpc(wallet_name)
46-
assert_equal(wallet.getwalletinfo()["descriptors"], False)
47-
assert_equal(wallet.getwalletinfo()["format"], "bdb")
46+
info = wallet.getwalletinfo()
47+
assert_equal(info["descriptors"], False)
48+
assert_equal(info["format"], "bdb")
49+
assert_equal(info["private_keys_enabled"], not disable_private_keys)
4850
return wallet
4951

5052
def assert_addr_info_equal(self, addr_info, addr_info_old):
@@ -187,11 +189,9 @@ def test_multisig(self):
187189

188190
# Some keys in multisig do not belong to this wallet
189191
self.log.info("Test migration of a wallet that has some keys in a multisig")
190-
self.nodes[0].createwallet(wallet_name="multisig1")
191-
multisig1 = self.nodes[0].get_wallet_rpc("multisig1")
192+
multisig1 = self.create_legacy_wallet("multisig1")
192193
ms_info = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
193194
ms_info2 = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
194-
assert_equal(multisig1.getwalletinfo()["descriptors"], False)
195195

196196
addr1 = ms_info["address"]
197197
addr2 = ms_info2["address"]
@@ -256,9 +256,7 @@ def test_other_watchonly(self):
256256

257257
# Wallet with an imported address. Should be the same thing as the multisig test
258258
self.log.info("Test migration of a wallet with watchonly imports")
259-
self.nodes[0].createwallet(wallet_name="imports0")
260-
imports0 = self.nodes[0].get_wallet_rpc("imports0")
261-
assert_equal(imports0.getwalletinfo()["descriptors"], False)
259+
imports0 = self.create_legacy_wallet("imports0")
262260

263261
# Exteranl address label
264262
imports0.setlabel(default.getnewaddress(), "external")
@@ -318,11 +316,7 @@ def test_no_privkeys(self):
318316

319317
# Migrating an actual watchonly wallet should not create a new watchonly wallet
320318
self.log.info("Test migration of a pure watchonly wallet")
321-
self.nodes[0].createwallet(wallet_name="watchonly0", disable_private_keys=True)
322-
watchonly0 = self.nodes[0].get_wallet_rpc("watchonly0")
323-
info = watchonly0.getwalletinfo()
324-
assert_equal(info["descriptors"], False)
325-
assert_equal(info["private_keys_enabled"], False)
319+
watchonly0 = self.create_legacy_wallet("watchonly0", disable_private_keys=True)
326320

327321
addr = default.getnewaddress()
328322
desc = default.getaddressinfo(addr)["desc"]
@@ -345,11 +339,7 @@ def test_no_privkeys(self):
345339

346340
# Migrating a wallet with pubkeys added to the keypool
347341
self.log.info("Test migration of a pure watchonly wallet with pubkeys in keypool")
348-
self.nodes[0].createwallet(wallet_name="watchonly1", disable_private_keys=True)
349-
watchonly1 = self.nodes[0].get_wallet_rpc("watchonly1")
350-
info = watchonly1.getwalletinfo()
351-
assert_equal(info["descriptors"], False)
352-
assert_equal(info["private_keys_enabled"], False)
342+
watchonly1 = self.create_legacy_wallet("watchonly1", disable_private_keys=True)
353343

354344
addr1 = default.getnewaddress(address_type="bech32")
355345
addr2 = default.getnewaddress(address_type="bech32")

0 commit comments

Comments
 (0)