Skip to content

Commit

Permalink
Tests: add tests for hmac
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Jan 17, 2024
1 parent 213d889 commit 6eefc6a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/python/test_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,15 @@ def test_sign_message(
pass
data = client.get_async_response()
checker.check_signature(account, tx, with_hash, data)


@pytest.mark.parametrize("account", [DEFAULT_ACCOUNT])
def test_hmac(
account: Account,
client: TezosClient) -> None:
"""Test the HMAC instruction."""

message = bytes.fromhex("0123456789abcdef")
data = client.hmac(account, message)
hmac = bytes.fromhex("dde436940ab1602029a49dc77e6263b633fa3567c4d8479820d4f77072369ac1")
assert data == hmac, f"No expected {hmac.hex()} but got {data.hex()}"
15 changes: 15 additions & 0 deletions test/python/utils/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,18 @@ def sign_message(self,
index=Index.LAST,
payload=message.raw):
yield

def hmac(self,
account: Account,
message: bytes) -> bytes:
"""Send the HMAC instruction."""

data: bytes = b''

data += account.path
data += message

return self._exchange(
ins=Ins.HMAC,
sig_scheme=account.sig_scheme,
payload=data)

0 comments on commit 6eefc6a

Please sign in to comment.