Skip to content

Commit

Permalink
test: add coverage for migrating watch-only script
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Dec 6, 2024
1 parent 932cd1e commit 297a876
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/functional/wallet_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from test_framework.key import ECPubKey
from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import COIN, CTransaction, CTxOut
from test_framework.script_util import key_to_p2pkh_script, script_to_p2sh_script, script_to_p2wsh_script
from test_framework.script_util import key_to_p2pkh_script, key_to_p2pk_script, script_to_p2sh_script, script_to_p2wsh_script
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
sha256sum_file,
)
from test_framework.wallet_util import (
get_generate_key,
generate_keypair,
)


Expand Down Expand Up @@ -1006,6 +1007,17 @@ def check_comments():

wallet.unloadwallet()

def test_migrate_simple_watch_only(self):
self.log.info("Test migrating a watch-only p2pk script")
wallet = self.create_legacy_wallet("bare_p2pk", blank=True)
_, pubkey = generate_keypair()
p2pk_script = key_to_p2pk_script(pubkey)
wallet.importaddress(address=p2pk_script.hex())
# Migrate wallet in the latest node
res, _ = self.migrate_and_get_rpc("bare_p2pk")
wo_wallet = self.master_node.get_wallet_rpc(res['watchonly_name'])
assert_equal(wo_wallet.listdescriptors()['descriptors'][0]['desc'], descsum_create(f'pk({pubkey.hex()})'))
wo_wallet.unloadwallet()

def run_test(self):
self.master_node = self.nodes[0]
Expand All @@ -1032,6 +1044,8 @@ def run_test(self):
self.test_avoidreuse()
self.test_preserve_tx_extra_info()
self.test_blank()
self.test_migrate_simple_watch_only()


if __name__ == '__main__':
WalletMigrationTest(__file__).main()

0 comments on commit 297a876

Please sign in to comment.