-
-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for internal abi type construction (#3662)
specifically test some internal sanity checks/validation --------- Co-authored-by: Charles Cooper <[email protected]>
- Loading branch information
1 parent
a87fb8c
commit 806dd90
Showing
3 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from vyper.abi_types import ( | ||
ABI_Bytes, | ||
ABI_BytesM, | ||
ABI_DynamicArray, | ||
ABI_FixedMxN, | ||
ABI_GIntM, | ||
ABI_String, | ||
) | ||
from vyper.exceptions import InvalidABIType | ||
|
||
cases_invalid_types = [ | ||
(ABI_GIntM, ((0, False), (7, False), (300, True), (300, False))), | ||
(ABI_FixedMxN, ((0, 0, False), (8, 0, False), (256, 81, True), (300, 80, False))), | ||
(ABI_BytesM, ((0,), (33,), (-10,))), | ||
(ABI_Bytes, ((-1,), (-69,))), | ||
(ABI_DynamicArray, ((ABI_GIntM(256, False), -1), (ABI_String(256), -10))), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("typ,params_variants", cases_invalid_types) | ||
def test_invalid_abi_types(assert_compile_failed, typ, params_variants): | ||
# double parametrization cannot work because the 2nd dimension is variable | ||
for params in params_variants: | ||
assert_compile_failed(lambda: typ(*params), InvalidABIType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters