Skip to content

Commit 02569f3

Browse files
committed
Add tests for get_create2_address() salt length validation
1 parent eca892b commit 02569f3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/core/utilities/test_address.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import pytest
22

3+
from web3.exceptions import (
4+
Web3ValidationError,
5+
)
36
from web3.utils.address import (
47
get_create2_address,
58
get_create_address,
@@ -69,3 +72,16 @@ def test_address_get_create_address(sender, nonce, expected):
6972
def test_address_get_create2_address(sender, salt, init_code, expected):
7073
actual = get_create2_address(sender, salt, init_code)
7174
assert actual == expected
75+
76+
77+
@pytest.mark.parametrize(
78+
"salt",
79+
("0x", "0x00", "0x0000", f"0x{'00' * 31}", f"0x{'00' * 33}"),
80+
)
81+
def test_salt_length_validation(salt):
82+
with pytest.raises(Web3ValidationError):
83+
get_create2_address(
84+
f"0x{'00' * 20}",
85+
salt,
86+
"0x00",
87+
)

0 commit comments

Comments
 (0)