mirror of
https://github.com/logos-blockchain/logos-blockchain-e2e-tests.git
synced 2026-01-07 23:53:07 +00:00
fix: cryptarchia headers query
- log body size only for size > 0
This commit is contained in:
parent
14fccadc54
commit
8127ca86b5
@ -40,4 +40,5 @@ class BaseClient:
|
||||
def print_request_size(self, data):
|
||||
body_size = len(data) if data else 0
|
||||
body_kb = body_size / 1024
|
||||
logger.debug(f"Request body size: {body_kb:.2f}kB")
|
||||
if body_size > 0:
|
||||
logger.debug(f"Request body size: {body_kb:.2f}kB")
|
||||
|
||||
@ -33,8 +33,9 @@ class REST(BaseClient):
|
||||
response = self.rest_call("get", "cryptarchia/info")
|
||||
return response.json()
|
||||
|
||||
def cryptarchia_headers(self, from_header_id, to_header_id):
|
||||
response = self.rest_call("get", f"cryptarchia/headers?from={quote(from_header_id, safe='')}" f"&to={quote(to_header_id, safe='')}")
|
||||
def cryptarchia_headers(self, query):
|
||||
path = f"cryptarchia/headers{'?' + query if query else ''}"
|
||||
response = self.rest_call("get", path)
|
||||
return response.json()
|
||||
|
||||
def da_add_share(self, data):
|
||||
|
||||
@ -43,8 +43,11 @@ def to_blob_id(n: int) -> list:
|
||||
return to_byte_list(n, 32)
|
||||
|
||||
|
||||
def to_header_id(n: int) -> list:
|
||||
return to_byte_list(n, 32)
|
||||
def to_header_id(n: int):
|
||||
if n < 0:
|
||||
raise ValueError("Input must be an unsigned integer (non-negative)")
|
||||
|
||||
return n.to_bytes(32, byteorder="big").hex()
|
||||
|
||||
|
||||
def to_byte_list(n: int, l: int) -> list:
|
||||
|
||||
@ -163,3 +163,6 @@ class NomosNode:
|
||||
|
||||
def send_get_storage_block_request(self, data):
|
||||
return self._api.storage_block(data)
|
||||
|
||||
def send_get_cryptarchia_headers_request(self, data):
|
||||
return self._api.cryptarchia_headers(data)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from urllib.parse import quote
|
||||
|
||||
import allure
|
||||
from tenacity import retry, stop_after_delay, wait_fixed
|
||||
|
||||
@ -7,6 +9,18 @@ from src.steps.common import StepsCommon
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
|
||||
def prepare_get_cryptarchia_headers_request(from_header_id, to_header_id):
|
||||
query_parts = []
|
||||
|
||||
if from_header_id is not None:
|
||||
query_parts.append(f"from={quote(from_header_id, safe='')}")
|
||||
|
||||
if to_header_id is not None:
|
||||
query_parts.append(f"to={quote(to_header_id, safe='')}")
|
||||
|
||||
return "&".join(query_parts)
|
||||
|
||||
|
||||
class StepsConsensus(StepsCommon):
|
||||
@allure.step
|
||||
def get_cryptarchia_headers(self, node, from_header_id=None, to_header_id=None, **kwargs):
|
||||
@ -14,10 +28,12 @@ class StepsConsensus(StepsCommon):
|
||||
timeout_duration = kwargs.get("timeout_duration", 65)
|
||||
interval = kwargs.get("interval", 0.1)
|
||||
|
||||
query = prepare_get_cryptarchia_headers_request(from_header_id, to_header_id)
|
||||
|
||||
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(interval), reraise=True)
|
||||
def get_headers():
|
||||
try:
|
||||
response = node.send_get_cryptarchia_headers_request(from_header_id, to_header_id)
|
||||
response = node.send_get_cryptarchia_headers_request(query)
|
||||
except Exception as ex:
|
||||
logger.error(f"Exception while retrieving cryptarchia headers: {ex}")
|
||||
raise
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user