Merge bitcoin/bitcoin#26638: test: prefer sqlite for wallet tests

17554efb60 test: prefer sqlite for wallet tests (S3RK)
8e0fabaabf test: make wallet_migration.py pass with both wallet flags (S3RK)

Pull request description:

  Fixes #26511

ACKs for top commit:
  MarcoFalke:
    review ACK 17554efb60
  achow101:
    ACK 17554efb60

Tree-SHA512: 97cae275998f07032feffe1b533d4747b8ff03c3c1fb830af69ee38cadb75fd58532956f66f79c0d275b00620ce53b0b5240f885e4f29b8bd4d0b6e6cbc683fa
This commit is contained in:
Andrew Chow 2022-12-20 18:05:53 -05:00
commit 8456bfac6b
No known key found for this signature in database
GPG key ID: 17565732E08E5E41
2 changed files with 14 additions and 24 deletions

View file

@ -214,11 +214,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.options.descriptors = None
elif self.options.descriptors is None:
# Some wallet is either required or optionally used by the test.
# Prefer BDB unless it isn't available
if self.is_bdb_compiled():
self.options.descriptors = False
elif self.is_sqlite_compiled():
# Prefer SQLite unless it isn't available
if self.is_sqlite_compiled():
self.options.descriptors = True
elif self.is_bdb_compiled():
self.options.descriptors = False
else:
# If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
# It still needs to exist and be None in order for tests to work however.

View file

@ -40,11 +40,13 @@ class WalletMigrationTest(BitcoinTestFramework):
assert_equal(file_magic, b'SQLite format 3\x00')
assert_equal(self.nodes[0].get_wallet_rpc(wallet_name).getwalletinfo()["format"], "sqlite")
def create_legacy_wallet(self, wallet_name):
self.nodes[0].createwallet(wallet_name=wallet_name)
def create_legacy_wallet(self, wallet_name, disable_private_keys=False):
self.nodes[0].createwallet(wallet_name=wallet_name, descriptors=False, disable_private_keys=disable_private_keys)
wallet = self.nodes[0].get_wallet_rpc(wallet_name)
assert_equal(wallet.getwalletinfo()["descriptors"], False)
assert_equal(wallet.getwalletinfo()["format"], "bdb")
info = wallet.getwalletinfo()
assert_equal(info["descriptors"], False)
assert_equal(info["format"], "bdb")
assert_equal(info["private_keys_enabled"], not disable_private_keys)
return wallet
def assert_addr_info_equal(self, addr_info, addr_info_old):
@ -187,11 +189,9 @@ class WalletMigrationTest(BitcoinTestFramework):
# Some keys in multisig do not belong to this wallet
self.log.info("Test migration of a wallet that has some keys in a multisig")
self.nodes[0].createwallet(wallet_name="multisig1")
multisig1 = self.nodes[0].get_wallet_rpc("multisig1")
multisig1 = self.create_legacy_wallet("multisig1")
ms_info = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
ms_info2 = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
assert_equal(multisig1.getwalletinfo()["descriptors"], False)
addr1 = ms_info["address"]
addr2 = ms_info2["address"]
@ -256,9 +256,7 @@ class WalletMigrationTest(BitcoinTestFramework):
# Wallet with an imported address. Should be the same thing as the multisig test
self.log.info("Test migration of a wallet with watchonly imports")
self.nodes[0].createwallet(wallet_name="imports0")
imports0 = self.nodes[0].get_wallet_rpc("imports0")
assert_equal(imports0.getwalletinfo()["descriptors"], False)
imports0 = self.create_legacy_wallet("imports0")
# Exteranl address label
imports0.setlabel(default.getnewaddress(), "external")
@ -318,11 +316,7 @@ class WalletMigrationTest(BitcoinTestFramework):
# Migrating an actual watchonly wallet should not create a new watchonly wallet
self.log.info("Test migration of a pure watchonly wallet")
self.nodes[0].createwallet(wallet_name="watchonly0", disable_private_keys=True)
watchonly0 = self.nodes[0].get_wallet_rpc("watchonly0")
info = watchonly0.getwalletinfo()
assert_equal(info["descriptors"], False)
assert_equal(info["private_keys_enabled"], False)
watchonly0 = self.create_legacy_wallet("watchonly0", disable_private_keys=True)
addr = default.getnewaddress()
desc = default.getaddressinfo(addr)["desc"]
@ -345,11 +339,7 @@ class WalletMigrationTest(BitcoinTestFramework):
# Migrating a wallet with pubkeys added to the keypool
self.log.info("Test migration of a pure watchonly wallet with pubkeys in keypool")
self.nodes[0].createwallet(wallet_name="watchonly1", disable_private_keys=True)
watchonly1 = self.nodes[0].get_wallet_rpc("watchonly1")
info = watchonly1.getwalletinfo()
assert_equal(info["descriptors"], False)
assert_equal(info["private_keys_enabled"], False)
watchonly1 = self.create_legacy_wallet("watchonly1", disable_private_keys=True)
addr1 = default.getnewaddress(address_type="bech32")
addr2 = default.getnewaddress(address_type="bech32")