From 995f0dabeda1ea7d7e527d2f920b3a544c05a110 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 3 Nov 2023 08:57:57 +0100 Subject: [PATCH] test: Add tests for util.inc_nonce --- tests/test_util.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_util.py b/tests/test_util.py index 5f2e950..cf64c30 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -28,11 +28,21 @@ from typing import List, Sequence, TypeVar import pytest -from secret_handshake.util import bytes_to_long, long_to_bytes, split_chunks +from secret_handshake.util import bytes_to_long, inc_nonce, long_to_bytes, split_chunks T = TypeVar("T") +@pytest.mark.parametrize("in_,out", ((b"\x00\x00\x00\x00", b"\x00" * 23 + b"\x01"),)) +def test_inc_nonce(in_: bytes, out: bytes) -> None: + """Test the inc_nonce function""" + + result = inc_nonce(in_) + + assert len(result) == 24 + assert result == out + + def test_split_chunks_is_generator() -> None: """Test if split_chunks returns a generator"""