functional_tests: Python epee binary lib and test /get_blocks.bin

Co-authored-by: selsta <selsta@sent.at>
This commit is contained in:
jeffro256
2026-07-17 22:35:43 -05:00
co-authored by selsta
parent 757679bb6a
commit 0c9956af80
5 changed files with 464 additions and 2 deletions
+28
View File
@@ -29,8 +29,18 @@
"""Daemon class to make rpc calls and store state."""
from . import epee_binary
from .rpc import JSONRPC
class DaemonBinary:
@staticmethod
def hash_list_to_blob(hash_list):
blob = bytes()
for h in hash_list:
assert len(h) == 64
blob += bytes.fromhex(h)
return blob
class Daemon(object):
def __init__(self, protocol='http', host='127.0.0.1', port=0, idx=0, restricted_rpc = False, username=None, password=None):
@@ -179,6 +189,24 @@ class Daemon(object):
return self.rpc.send_json_rpc_request(getblockheadersrange)
get_block_headers_range = getblockheadersrange
def get_blocks_fast(self, start_height, block_ids, requested_info = 0,
pool_info_since = 0, prune = True, no_miner_tx = False,
max_block_count = 0, block_ids_exclusive = False):
get_blocks_fast = {
'requested_info': requested_info,
'block_ids': DaemonBinary.hash_list_to_blob(block_ids),
'start_height': start_height,
'prune': prune,
'no_miner_tx': no_miner_tx,
'block_ids_exclusive': block_ids_exclusive,
'pool_info_since': pool_info_since,
'max_block_count': max_block_count
}
res = self.rpc.send_binary_request("/getblocks.bin", get_blocks_fast)
if 'top_block_hash' in res:
res['top_block_hash'] = res['top_block_hash'].hex()
return res
def get_connections(self, client = ""):
get_connections = {
'client': client,