mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 16:53:52 +02:00
test: Simple test for importing unused(KEY)
This commit is contained in:
@@ -65,6 +65,29 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
assert_equal(result[0]['error']['code'], error_code)
|
||||
assert_equal(result[0]['error']['message'], error_message)
|
||||
|
||||
def test_import_unused_key(self):
|
||||
self.log.info("Test import of unused(KEY)")
|
||||
self.nodes[0].createwallet(wallet_name="import_unused", blank=True)
|
||||
wallet = self.nodes[0].get_wallet_rpc("import_unused")
|
||||
|
||||
assert_equal(len(wallet.gethdkeys()), 0)
|
||||
|
||||
xprv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg"
|
||||
xpub = "tpubD6NzVbkrYhZ4YNXVQbNhMK1WqguFsUXceaVJKbmno2aZ3B6QfbMeraaYvnBSGpV3vxLyTTK9DYT1yoEck4XUScMzXoQ2U2oSmE2JyMedq3H"
|
||||
self.test_importdesc({"desc":descsum_create(f"unused({xpub})"),
|
||||
"timestamp": "now"},
|
||||
success=False,
|
||||
error_code=-4,
|
||||
error_message='Cannot import descriptor without private keys to a wallet with private keys enabled',
|
||||
wallet=wallet)
|
||||
self.test_importdesc({"timestamp": "now", "desc": descsum_create(f"unused({xprv})")},
|
||||
success=True,
|
||||
wallet=wallet)
|
||||
hdkeys = wallet.gethdkeys()
|
||||
assert_equal(len(hdkeys), 1)
|
||||
assert_equal(hdkeys[0]["xpub"], xpub)
|
||||
wallet.unloadwallet()
|
||||
|
||||
def run_test(self):
|
||||
self.log.info('Setting up wallets')
|
||||
self.nodes[0].createwallet(wallet_name='w0', disable_private_keys=False)
|
||||
@@ -822,5 +845,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
)
|
||||
|
||||
|
||||
self.test_import_unused_key()
|
||||
|
||||
if __name__ == '__main__':
|
||||
ImportDescriptorsTest(__file__).main()
|
||||
|
||||
Reference in New Issue
Block a user