diff --git a/test/python/test_instructions.py b/test/python/test_instructions.py index 47df8211..28cd3ebe 100644 --- a/test/python/test_instructions.py +++ b/test/python/test_instructions.py @@ -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()}" diff --git a/test/python/utils/client.py b/test/python/utils/client.py index ca6757f6..a31e4ad1 100644 --- a/test/python/utils/client.py +++ b/test/python/utils/client.py @@ -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)