-
-
Notifications
You must be signed in to change notification settings - Fork 823
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: Refactor assert_tx_failed into a context #3706
Merged
charles-cooper
merged 17 commits into
vyperlang:master
from
DanielSchiavini:assert_tx_failed
Dec 23, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b6a63ad
Update lint dependencies
DanielSchiavini b028b0c
Merge branch 'master' of github.com:vyperlang/vyper into lint-depende…
DanielSchiavini 0920eb6
Fix tests and review comment
DanielSchiavini 19aff28
Refactor assert_tx_failed
DanielSchiavini 7147671
Inline search_for_sublist
DanielSchiavini a0d1d58
Rename fixture
DanielSchiavini be72dec
Lint fix
DanielSchiavini cd07723
Review
DanielSchiavini 0abe8cc
Review comments
DanielSchiavini e4182f2
Review comments
DanielSchiavini cde70ba
Review comments
DanielSchiavini 3abae3d
Review comments
DanielSchiavini 87c220d
Merge branch 'master' of github.com:vyperlang/vyper into assert_tx_fa…
DanielSchiavini 5a46f88
Linting
DanielSchiavini 09f6009
Update expectation
DanielSchiavini 0b5e2b7
Merge branch 'master' into assert_tx_failed
charles-cooper 219bfce
remove remaining assert_tx_failed
charles-cooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
|
||
|
||
@pytest.mark.parametrize("denom,multiplier", wei_denoms.items()) | ||
def test_wei_uint256(get_contract, assert_tx_failed, denom, multiplier): | ||
def test_wei_uint256(get_contract, tx_failed, denom, multiplier): | ||
code = f""" | ||
@external | ||
def foo(a: uint256) -> uint256: | ||
|
@@ -36,11 +36,12 @@ def foo(a: uint256) -> uint256: | |
assert c.foo(value) == value * (10**multiplier) | ||
|
||
value = (2**256 - 1) // (10 ** (multiplier - 1)) | ||
assert_tx_failed(lambda: c.foo(value)) | ||
with tx_failed(): | ||
c.foo(value) | ||
|
||
|
||
@pytest.mark.parametrize("denom,multiplier", wei_denoms.items()) | ||
def test_wei_int128(get_contract, assert_tx_failed, denom, multiplier): | ||
def test_wei_int128(get_contract, tx_failed, denom, multiplier): | ||
code = f""" | ||
@external | ||
def foo(a: int128) -> uint256: | ||
|
@@ -54,7 +55,7 @@ def foo(a: int128) -> uint256: | |
|
||
|
||
@pytest.mark.parametrize("denom,multiplier", wei_denoms.items()) | ||
def test_wei_decimal(get_contract, assert_tx_failed, denom, multiplier): | ||
def test_wei_decimal(get_contract, tx_failed, denom, multiplier): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused fixture |
||
code = f""" | ||
@external | ||
def foo(a: decimal) -> uint256: | ||
|
@@ -69,20 +70,21 @@ def foo(a: decimal) -> uint256: | |
|
||
@pytest.mark.parametrize("value", (-1, -(2**127))) | ||
@pytest.mark.parametrize("data_type", ["decimal", "int128"]) | ||
def test_negative_value_reverts(get_contract, assert_tx_failed, value, data_type): | ||
def test_negative_value_reverts(get_contract, tx_failed, value, data_type): | ||
code = f""" | ||
@external | ||
def foo(a: {data_type}) -> uint256: | ||
return as_wei_value(a, "ether") | ||
""" | ||
|
||
c = get_contract(code) | ||
assert_tx_failed(lambda: c.foo(value)) | ||
with tx_failed(): | ||
c.foo(value) | ||
|
||
|
||
@pytest.mark.parametrize("denom,multiplier", wei_denoms.items()) | ||
@pytest.mark.parametrize("data_type", ["decimal", "int128", "uint256"]) | ||
def test_zero_value(get_contract, assert_tx_failed, denom, multiplier, data_type): | ||
def test_zero_value(get_contract, tx_failed, denom, multiplier, data_type): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused fixture |
||
code = f""" | ||
@external | ||
def foo(a: {data_type}) -> uint256: | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused fixture