Skip to content

Commit

Permalink
nearly there!
Browse files Browse the repository at this point in the history
  • Loading branch information
odesenfans committed Sep 14, 2023
1 parent b99a760 commit 10c7489
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/aleph_vrf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def generate_response_hash_from_message(message: PostMessage) -> VRFResponseHash
execution_id=content["execution_id"],
vrf_request=ItemHash(content["vrf_request"]),
random_bytes_hash=content["random_bytes_hash"],
message_hash=content["message_hash"],
message_hash=message.item_hash,
)


Expand Down
13 changes: 11 additions & 2 deletions tests/executor/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from aleph_message.models import ItemType, MessageType, PostContent, Chain, ItemHash

from aleph_vrf.models import VRFRequest, VRFResponseHash, VRFResponse
from aleph_vrf.models import VRFRequest, VRFResponseHash, VRFResponse, VRFRandomBytes


@pytest.mark.asyncio
Expand Down Expand Up @@ -54,6 +54,7 @@ def mock_vrf_request() -> VRFRequest:

vrf_request = VRFRequest(
nb_bytes=32,
nb_executors=4,
nonce=42,
vrf_function="deca" * 16,
request_id=request_id,
Expand Down Expand Up @@ -110,4 +111,12 @@ async def test_normal_request_flow(

resp = await executor_client.post(f"/publish/{response_hash.message_hash}")
assert resp.status == 200, await resp.text()
print(await resp.text())
response_json = await resp.json()

random_bytes = VRFRandomBytes.parse_obj(response_json["data"])

assert random_bytes.request_id == mock_vrf_request.request_id
assert random_bytes.execution_id == response_hash.execution_id
assert random_bytes.vrf_request == item_hash
assert random_bytes.random_bytes_hash == response_hash.random_bytes_hash
# TODO: compare random number with hash

0 comments on commit 10c7489

Please sign in to comment.