forked from vyperlang/vyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_code_size.py
More file actions
48 lines (39 loc) · 833 Bytes
/
test_code_size.py
File metadata and controls
48 lines (39 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest
from pytest import (
raises,
)
from vyper import (
compiler,
)
from vyper.exceptions import (
TypeMismatchException,
)
fail_list = [
"""
@public
def foo() -> int128:
x: int128 = 45
return x.codesize
""",
"""
@public
def foo() -> int128(wei):
x: address = 0x1234567890123456789012345678901234567890
return x.codesize
"""
]
@pytest.mark.parametrize('bad_code', fail_list)
def test_block_fail(bad_code):
with raises(TypeMismatchException):
compiler.compile_code(bad_code)
valid_list = [
"""
@public
def foo() -> int128:
x: address = 0x1234567890123456789012345678901234567890
return x.codesize
"""
]
@pytest.mark.parametrize('good_code', valid_list)
def test_block_success(good_code):
assert compiler.compile_code(good_code) is not None