sending hash and cursor as hex

This commit is contained in:
Gabriel mermelstein 2025-01-30 12:58:50 +02:00
parent 290acadb60
commit 5b045cc5a0
No known key found for this signature in database
GPG Key ID: 82B8134785FEAE0D
3 changed files with 17 additions and 5 deletions

View File

@ -26,6 +26,18 @@ def to_base64(input_data):
return base64_encoded.decode()
def to_hex(input_data):
if isinstance(input_data, str):
input_bytes = input_data.encode()
elif isinstance(input_data, int):
input_bytes = str(input_data).encode()
elif isinstance(input_data, bytes):
input_bytes = input_data
else:
input_bytes = str(input_data).encode()
return "0x" + input_bytes.hex()
def attach_allure_file(file):
logger.debug(f"Attaching file {file}")
allure.attach.file(file, name=os.path.basename(file), attachment_type=allure.attachment_type.TEXT)

View File

@ -1,6 +1,6 @@
import pytest
from src.env_vars import NODE_1, NODE_2
from src.libs.common import to_base64
from src.libs.common import to_base64, to_hex
from src.node.store_response import StoreResponse
from src.steps.store import StepsStore
@ -70,8 +70,8 @@ class TestCursor(StepsStore):
def test_passing_invalid_cursor(self):
for i in range(4):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
# creating a invalid base64 cursor
cursor = to_base64("test")
# creating a invalid hex cursor
cursor = to_hex("test")
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=100, cursor=cursor)
assert not store_response.messages, "Messages found"

View File

@ -1,6 +1,6 @@
import pytest
from src.env_vars import NODE_2
from src.libs.common import to_base64
from src.libs.common import to_base64, to_hex
from src.libs.custom_logger import get_custom_logger
from src.steps.store import StepsStore
from src.test_data import SAMPLE_INPUTS
@ -46,7 +46,7 @@ class TestHashes(StepsStore):
def test_store_with_invalid_hash(self):
for i in range(4):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
invalid_hash = to_base64("test")
invalid_hash = to_hex("test")
for node in self.store_nodes:
try:
store_response = self.get_messages_from_store(node, hashes=invalid_hash, page_size=50)