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

@@ -20,6 +20,7 @@ import time
from . import coverage
from .authproxy import AuthServiceProxy, JSONRPCException
from .descriptors import descsum_create
from collections.abc import Callable
from typing import Optional, Union
@@ -609,3 +610,13 @@ def sync_txindex(test_framework, node):
sync_start = int(time.time())
test_framework.wait_until(lambda: node.getindexinfo("txindex")["txindex"]["synced"])
test_framework.log.debug(f"Synced in {time.time() - sync_start} seconds")
def wallet_importprivkey(wallet_rpc, privkey, timestamp, *, label=""):
desc = descsum_create("combo(" + privkey + ")")
req = [{
"desc": desc,
"timestamp": timestamp,
"label": label,
}]
import_res = wallet_rpc.importdescriptors(req)
assert_equal(import_res[0]["success"], True)