33
44pytestmark = pytest .mark .unit
55
6+
67def test_from_string_without_prefix ():
78 """Test creating EvmAddress from valid 40-character hex string."""
89 hex_str = "1234567890abcdef1234567890abcdef12345678"
@@ -12,6 +13,7 @@ def test_from_string_without_prefix():
1213 assert addr .to_string () == hex_str
1314 assert len (addr .address_bytes ) == 20
1415
16+
1517def test_from_string_with_0x_prefix ():
1618 """Test creating EvmAddress from valid hex string with '0x' prefix."""
1719 hex_str = "0x1234567890abcdef1234567890abcdef12345678"
@@ -21,16 +23,19 @@ def test_from_string_with_0x_prefix():
2123 assert addr .to_string () == hex_str [2 :]
2224 assert len (addr .address_bytes ) == 20
2325
26+
2427def test_from_string_invalid_length ():
2528 """Test ValueError for invalid hex string length."""
2629 with pytest .raises (ValueError ):
2730 EvmAddress .from_string ("0x1234" )
2831
32+
2933def test_from_string_invalid_hex_characters ():
3034 """Test ValueError for invalid hex characters."""
3135 with pytest .raises (ValueError ):
3236 EvmAddress .from_string ("0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" )
3337
38+
3439def test_from_bytes_valid ():
3540 """Test creating EvmAddress from 20 bytes."""
3641 raw = bytes (range (20 ))
@@ -40,11 +45,13 @@ def test_from_bytes_valid():
4045 assert addr .address_bytes == raw
4146 assert addr .to_string () == raw .hex ()
4247
48+
4349def test_from_bytes_invalid_length ():
4450 """Test ValueError for byte length not equal to 20."""
4551 with pytest .raises (ValueError ):
4652 EvmAddress .from_bytes (bytes (range (10 )))
4753
54+
4855def test_equality ():
4956 """Test equality and hash behavior."""
5057 raw = bytes (range (20 ))
0 commit comments