Skip to content

Commit 3378644

Browse files
committed
chore: move TestDecodeHex class into param_utils_test to better match location
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent 3579556 commit 3378644

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

tests/tck/contract_handler_test.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,11 @@
1111
from tck.errors import JsonRpcError
1212
from tck.handlers import contract as contract_handlers
1313
from tck.param.contract import CreateContractParams
14-
from tck.util.param_utils import decode_hex
1514

1615

1716
pytestmark = pytest.mark.unit
1817

1918

20-
class TestDecodeHex:
21-
def test_decodes_plain_hex(self):
22-
assert decode_hex("60006000") == b"\x60\x00\x60\x00"
23-
24-
def test_decodes_0x_prefixed_hex(self):
25-
assert decode_hex("0x60006000") == b"\x60\x00\x60\x00"
26-
27-
def test_rejects_non_hex_characters(self):
28-
with pytest.raises(ValueError):
29-
decode_hex("0xZZ")
30-
31-
def test_rejects_odd_length(self):
32-
with pytest.raises(ValueError):
33-
decode_hex("0x123")
34-
35-
def test_rejects_embedded_whitespace(self):
36-
"""bytes.fromhex alone would accept "60 00"."""
37-
with pytest.raises(ValueError):
38-
decode_hex("60 00")
39-
40-
def test_rejects_surrounding_whitespace(self):
41-
with pytest.raises(ValueError):
42-
decode_hex(" 6000\n")
43-
44-
4519
class TestCreateContractParams:
4620
def test_parses_all_params(self):
4721
params = CreateContractParams.parse_json_params(

tests/tck/param_utils_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Test cases for the TCK param_utils helpers."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
7+
from tck.util.param_utils import decode_hex
8+
9+
10+
pytestmark = pytest.mark.unit
11+
12+
13+
class TestDecodeHex:
14+
def test_decodes_plain_hex(self):
15+
assert decode_hex("60006000") == b"\x60\x00\x60\x00"
16+
17+
def test_decodes_0x_prefixed_hex(self):
18+
assert decode_hex("0x60006000") == b"\x60\x00\x60\x00"
19+
20+
def test_rejects_non_hex_characters(self):
21+
with pytest.raises(ValueError):
22+
decode_hex("0xZZ")
23+
24+
def test_rejects_odd_length(self):
25+
with pytest.raises(ValueError):
26+
decode_hex("0x123")
27+
28+
def test_rejects_embedded_whitespace(self):
29+
"""bytes.fromhex alone would accept "60 00"."""
30+
with pytest.raises(ValueError):
31+
decode_hex("60 00")
32+
33+
def test_rejects_surrounding_whitespace(self):
34+
with pytest.raises(ValueError):
35+
decode_hex(" 6000\n")

0 commit comments

Comments
 (0)