Merge bitcoin/bitcoin#26638: test: prefer sqlite for wallet tests
17554efb60test: prefer sqlite for wallet tests (S3RK)8e0fabaabftest: make wallet_migration.py pass with both wallet flags (S3RK) Pull request description: Fixes #26511 ACKs for top commit: MarcoFalke: review ACK17554efb60achow101: ACK17554efb60Tree-SHA512: 97cae275998f07032feffe1b533d4747b8ff03c3c1fb830af69ee38cadb75fd58532956f66f79c0d275b00620ce53b0b5240f885e4f29b8bd4d0b6e6cbc683fa
This commit is contained in:
2 files changed
+14
-24
No files matched your search
@@ -214,11 +214,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||||||
self.options.descriptors = None
|
self.options.descriptors = None
|
||||||
elif self.options.descriptors is None:
|
elif self.options.descriptors is None:
|
||||||
# Some wallet is either required or optionally used by the test.
|
# Some wallet is either required or optionally used by the test.
|
||||||
# Prefer BDB unless it isn't available
|
# Prefer SQLite unless it isn't available
|
||||||
if self.is_bdb_compiled():
|
if self.is_sqlite_compiled():
|
||||||
self.options.descriptors = False
|
|
||||||
elif self.is_sqlite_compiled():
|
|
||||||
self.options.descriptors = True
|
self.options.descriptors = True
|
||||||
|
elif self.is_bdb_compiled():
|
||||||
|
self.options.descriptors = False
|
||||||
else:
|
else:
|
||||||
# If neither are compiled, tests requiring a wallet will be skipped and the value of self.options.descriptors won't matter
|
# 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.
|
# It still needs to exist and be None in order for tests to work however.
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||||||
assert_equal(file_magic, b'SQLite format 3\x00')
|
assert_equal(file_magic, b'SQLite format 3\x00')
|
||||||
assert_equal(self.nodes[0].get_wallet_rpc(wallet_name).getwalletinfo()["format"], "sqlite")
|
assert_equal(self.nodes[0].get_wallet_rpc(wallet_name).getwalletinfo()["format"], "sqlite")
|
||||||
|
|
||||||
def create_legacy_wallet(self, wallet_name):
|
def create_legacy_wallet(self, wallet_name, disable_private_keys=False):
|
||||||
self.nodes[0].createwallet(wallet_name=wallet_name)
|
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)
|
wallet = self.nodes[0].get_wallet_rpc(wallet_name)
|
||||||
assert_equal(wallet.getwalletinfo()["descriptors"], False)
|
info = wallet.getwalletinfo()
|
||||||
assert_equal(wallet.getwalletinfo()["format"], "bdb")
|
assert_equal(info["descriptors"], False)
|
||||||
|
assert_equal(info["format"], "bdb")
|
||||||
|
assert_equal(info["private_keys_enabled"], not disable_private_keys)
|
||||||
return wallet
|
return wallet
|
||||||
|
|
||||||
def assert_addr_info_equal(self, addr_info, addr_info_old):
|
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
|
# 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.log.info("Test migration of a wallet that has some keys in a multisig")
|
||||||
self.nodes[0].createwallet(wallet_name="multisig1")
|
multisig1 = self.create_legacy_wallet("multisig1")
|
||||||
multisig1 = self.nodes[0].get_wallet_rpc("multisig1")
|
|
||||||
ms_info = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
|
ms_info = multisig1.addmultisigaddress(2, [multisig1.getnewaddress(), pub1, pub2])
|
||||||
ms_info2 = 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"]
|
addr1 = ms_info["address"]
|
||||||
addr2 = ms_info2["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
|
# 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.log.info("Test migration of a wallet with watchonly imports")
|
||||||
self.nodes[0].createwallet(wallet_name="imports0")
|
imports0 = self.create_legacy_wallet("imports0")
|
||||||
imports0 = self.nodes[0].get_wallet_rpc("imports0")
|
|
||||||
assert_equal(imports0.getwalletinfo()["descriptors"], False)
|
|
||||||
|
|
||||||
# Exteranl address label
|
# Exteranl address label
|
||||||
imports0.setlabel(default.getnewaddress(), "external")
|
imports0.setlabel(default.getnewaddress(), "external")
|
||||||
@@ -318,11 +316,7 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Migrating an actual watchonly wallet should not create a new watchonly wallet
|
# Migrating an actual watchonly wallet should not create a new watchonly wallet
|
||||||
self.log.info("Test migration of a pure 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.create_legacy_wallet("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)
|
|
||||||
|
|
||||||
addr = default.getnewaddress()
|
addr = default.getnewaddress()
|
||||||
desc = default.getaddressinfo(addr)["desc"]
|
desc = default.getaddressinfo(addr)["desc"]
|
||||||
@@ -345,11 +339,7 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Migrating a wallet with pubkeys added to the keypool
|
# Migrating a wallet with pubkeys added to the keypool
|
||||||
self.log.info("Test migration of a pure watchonly wallet with pubkeys in 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.create_legacy_wallet("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)
|
|
||||||
|
|
||||||
addr1 = default.getnewaddress(address_type="bech32")
|
addr1 = default.getnewaddress(address_type="bech32")
|
||||||
addr2 = default.getnewaddress(address_type="bech32")
|
addr2 = default.getnewaddress(address_type="bech32")
|
||||||
|
|||||||
Reference in new issue
Block a user