mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 02:11:24 +02:00
test: Allow pathlib.Path as RPC argument via authproxy
Also, add datadir_path property to TestNode
This commit is contained in:
@ -39,6 +39,7 @@ from http import HTTPStatus
|
||||
import http.client
|
||||
import json
|
||||
import logging
|
||||
import pathlib
|
||||
import socket
|
||||
import time
|
||||
import urllib.parse
|
||||
@ -62,6 +63,8 @@ class JSONRPCException(Exception):
|
||||
def EncodeDecimal(o):
|
||||
if isinstance(o, decimal.Decimal):
|
||||
return str(o)
|
||||
if isinstance(o, pathlib.Path):
|
||||
return str(o)
|
||||
raise TypeError(repr(o) + " is not JSON serializable")
|
||||
|
||||
class AuthServiceProxy():
|
||||
|
@ -22,7 +22,10 @@ import shlex
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from .authproxy import JSONRPCException
|
||||
from .authproxy import (
|
||||
JSONRPCException,
|
||||
EncodeDecimal,
|
||||
)
|
||||
from .descriptors import descsum_create
|
||||
from .p2p import P2P_SUBVERSION
|
||||
from .util import (
|
||||
@ -35,7 +38,6 @@ from .util import (
|
||||
rpc_url,
|
||||
wait_until_helper,
|
||||
p2p_port,
|
||||
EncodeDecimal,
|
||||
)
|
||||
|
||||
BITCOIND_PROC_WAIT_TIMEOUT = 60
|
||||
@ -405,9 +407,13 @@ class TestNode():
|
||||
with open(self.bitcoinconf, 'w', encoding='utf8') as conf:
|
||||
conf.write(conf_data)
|
||||
|
||||
@property
|
||||
def datadir_path(self) -> Path:
|
||||
return Path(self.datadir)
|
||||
|
||||
@property
|
||||
def chain_path(self) -> Path:
|
||||
return Path(self.datadir) / self.chain
|
||||
return self.datadir_path / self.chain
|
||||
|
||||
@property
|
||||
def debug_log_path(self) -> Path:
|
||||
|
@ -211,12 +211,6 @@ def check_json_precision():
|
||||
raise RuntimeError("JSON encode/decode loses precision")
|
||||
|
||||
|
||||
def EncodeDecimal(o):
|
||||
if isinstance(o, Decimal):
|
||||
return str(o)
|
||||
raise TypeError(repr(o) + " is not JSON serializable")
|
||||
|
||||
|
||||
def count_bytes(hex_string):
|
||||
return len(bytearray.fromhex(hex_string))
|
||||
|
||||
|
Reference in New Issue
Block a user