Skip to content

Commit 37a7742

Browse files
chore: format black tests/unit/crypto_utils_test.py (hiero-ledger#1738)
Signed-off-by: AkshayKumarSahu <akshaykumar15031999@gmail.com> Signed-off-by: Akshay Kumar <akshaykumar15031999@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d739cbb commit 37a7742

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
77
## [Unreleased]
88

99
### Tests
10+
- Format `tests/unit/crypto_utils_test.py` with black for code style consistency (#1524)
1011
- Standardize formatting of `tests/unit/entity_id_helper_test.py` using Black for consistent code style across the test suite (#1527)
1112

1213
- Added tests for ProtoBuf Training Example Implementation

tests/unit/crypto_utils_test.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for crypto_utils module."""
2+
23
from cryptography.hazmat.primitives.asymmetric import ec
34
import pytest
45

@@ -15,13 +16,22 @@
1516
def test_keccak256():
1617
"""Test keccak256 hashing."""
1718
# Known vector: empty string -> c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
18-
assert keccak256(b"").hex() == "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
19+
assert (
20+
keccak256(b"").hex()
21+
== "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
22+
)
1923

2024
# "hello" -> 1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
21-
assert keccak256(b"hello").hex() == "1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
25+
assert (
26+
keccak256(b"hello").hex()
27+
== "1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
28+
)
2229

2330
# "Transfer" -> 461a29a8a7db848c0827103038dd4776114eb182e0717208d0a793574936353d
24-
assert keccak256(b"Transfer").hex() == "f099cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
31+
assert (
32+
keccak256(b"Transfer").hex()
33+
== "f099cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
34+
)
2535

2636

2737
def test_compress_point_unchecked():
@@ -57,19 +67,19 @@ def test_decompress_point():
5767
assert y == nums.y
5868

5969
# Test uncompressed 65-byte format (0x04 + x + y)
60-
uncompressed = b'\x04' + nums.x.to_bytes(32, 'big') + nums.y.to_bytes(32, 'big')
70+
uncompressed = b"\x04" + nums.x.to_bytes(32, "big") + nums.y.to_bytes(32, "big")
6171
x2, y2 = decompress_point(uncompressed)
6272
assert x2 == nums.x
6373
assert y2 == nums.y
6474

6575
# Test invalid length
6676
with pytest.raises(ValueError, match="Not recognized"):
67-
decompress_point(b'\x04' * 10)
77+
decompress_point(b"\x04" * 10)
6878

6979
# Test invalid prefix
7080
with pytest.raises(ValueError, match="Not recognized"):
7181
# 0x05 is invalid prefix for 33-byte point
72-
invalid_point = b'\x05' + nums.x.to_bytes(32, 'big')
82+
invalid_point = b"\x05" + nums.x.to_bytes(32, "big")
7383
decompress_point(invalid_point)
7484

7585

@@ -80,7 +90,7 @@ def test_compress_with_cryptography():
8090
nums = pub.public_numbers()
8191

8292
# Create uncompressed
83-
uncompressed = b'\x04' + nums.x.to_bytes(32, 'big') + nums.y.to_bytes(32, 'big')
93+
uncompressed = b"\x04" + nums.x.to_bytes(32, "big") + nums.y.to_bytes(32, "big")
8494

8595
compressed_via_lib = compress_with_cryptography(uncompressed)
8696
compressed_manual = compress_point_unchecked(nums.x, nums.y)

0 commit comments

Comments
 (0)