test: Replace importprivkey with wallet_importprivkey

importprivkey was a legacy wallet only RPC which had a helper for
descriptor wallets in tests. Add wallet_importprivkey helper and use it
wherever importprivkey is used (other than backward compatibility tests)
This commit is contained in:
Ava Chow
2025-05-08 11:26:34 -07:00
parent 94c87bbbd0
commit fcc457573f
10 changed files with 33 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
wallet_importprivkey,
)
from test_framework.wallet_util import generate_keypair, WalletUnlock
@@ -65,7 +66,7 @@ class CreateWalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w3.getnewaddress)
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w3.getrawchangeaddress)
# Import private key
w3.importprivkey(generate_keypair(wif=True)[0])
wallet_importprivkey(w3, generate_keypair(wif=True)[0], "now")
# Imported private keys are currently ignored by the keypool
assert_equal(w3.getwalletinfo()['keypoolsize'], 0)
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w3.getnewaddress)