Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[test]: add more transient storage tests #3883

Merged
merged 39 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4820822
add grammar fix from 3874
tserg Mar 23, 2024
d8ec500
add tests
tserg Mar 23, 2024
ee7c5ed
revert changes
tserg Mar 23, 2024
5c9d3c4
fix tests
tserg Mar 23, 2024
78fb377
modify _get_contract
tserg Mar 23, 2024
52adc7b
add new exception
tserg Mar 23, 2024
419dd0c
fix lint
tserg Mar 23, 2024
2257b21
add transient marker
tserg Mar 24, 2024
329431e
clean up
tserg Mar 24, 2024
68a26e3
clarify transient marker description
tserg Mar 24, 2024
2d0a8df
add more assertions
tserg Mar 24, 2024
31d9af9
remove blank line
tserg Mar 25, 2024
f66ade2
Revert "add grammar fix from 3874"
tserg Mar 26, 2024
82ed420
fix grammar to support tstorage
cyberthirst Mar 21, 2024
0d05989
apply bts suggestions
tserg Mar 26, 2024
ef1b00b
update markers in setup.cfg
tserg Mar 26, 2024
19038ee
revert new exception
tserg Mar 27, 2024
51ec461
change marker
tserg Mar 27, 2024
4be6e3d
fix lint
tserg Mar 27, 2024
70e5bc5
Merge branch 'master' of https://github.com/vyperlang/vyper into test…
tserg Mar 27, 2024
4bc949f
remove xfail strict
tserg Mar 27, 2024
ee13d8f
add view and pure tests
tserg Mar 27, 2024
ed7629e
assert evm version
tserg Mar 27, 2024
0d96ef6
fix lint
tserg Mar 27, 2024
f58c85d
use pytest runtest setup
tserg Mar 27, 2024
6bc88ca
use pytest_runtest_call
tserg Mar 27, 2024
d0c5751
move pure test
tserg Mar 27, 2024
5de3564
add view test
tserg Mar 27, 2024
9b4c209
use file level marker
tserg Mar 27, 2024
07bfffa
add complex transient storage tests
cyberthirst Mar 29, 2024
8ee1061
fix transient modules test
cyberthirst Mar 29, 2024
2948300
Merge pull request #2 from cyberthirst/tests/transient
tserg Mar 29, 2024
d3c5b07
fix lint
tserg Mar 29, 2024
3e8f540
Merge branch 'master' of https://github.com/vyperlang/vyper into test…
tserg Apr 2, 2024
7e57b4a
fix lint
tserg Apr 2, 2024
cccce57
Merge branch 'master' of https://github.com/vyperlang/vyper into test…
tserg Apr 3, 2024
394ae32
use tx_failed
tserg Apr 4, 2024
e2356c7
Merge branch 'master' of https://github.com/vyperlang/vyper into test…
tserg Apr 4, 2024
2f1b4f4
minor suggestions from code review
charles-cooper Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ testpaths = tests
xfail_strict = true
markers =
fuzzing: Run Hypothesis fuzz test suite (deselect with '-m "not fuzzing"')
requires_evm_version(version): Mark tests that require at least a specific EVM version and would throw `EvmVersionException` otherwise
venom_xfail: mark a test case as a regression (expected to fail) under the venom pipeline
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from vyper.codegen.ir_node import IRnode
from vyper.compiler.input_bundle import FilesystemInputBundle, InputBundle
from vyper.compiler.settings import OptimizationLevel, Settings, _set_debug_mode
from vyper.evm.opcodes import version_check
from vyper.exceptions import EvmVersionException
from vyper.ir import compile_ir, optimizer
from vyper.utils import ERC5202_PREFIX

Expand Down Expand Up @@ -580,3 +582,14 @@ def fn(exception=TransactionFailed, exc_text=None):
assert exc_text in str(excinfo.value), (exc_text, excinfo.value)

return fn


def pytest_runtest_call(item):
marker = item.get_closest_marker("requires_evm_version")
if marker:
assert len(marker.args) == 1
version = marker.args[0]
if not version_check(begin=version):
item.add_marker(
pytest.mark.xfail(reason="Wrong EVM version", raises=EvmVersionException)
charles-cooper marked this conversation as resolved.
Show resolved Hide resolved
)
14 changes: 14 additions & 0 deletions tests/functional/codegen/features/decorators/test_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,17 @@ def foo() -> uint256:
"""
with pytest.raises(FunctionDeclarationException):
compile_code(code)


@pytest.mark.requires_evm_version("cancun")
def test_invalid_transient_access():
code = """
x: transient(uint256)

@external
@pure
def foo() -> uint256:
return self.x
"""
with pytest.raises(StateAccessViolation):
compile_code(code)
16 changes: 16 additions & 0 deletions tests/functional/codegen/features/decorators/test_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from vyper.exceptions import FunctionDeclarationException


Expand All @@ -15,6 +17,20 @@ def foo() -> int128:
print("Passed constant function test")


@pytest.mark.requires_evm_version("cancun")
def test_transient_test(get_contract):
code = """
x: transient(uint256)

@external
@view
def foo() -> uint256:
return self.x
"""
c = get_contract(code)
assert c.foo() == 0


def test_invalid_constant_and_payable(
get_contract_with_gas_estimation_for_constants, assert_compile_failed
):
Expand Down
Loading
Loading