Skip to content

Commit

Permalink
add abi decode test
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberthirst committed Apr 18, 2024
1 parent 8983f9e commit 2095d29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion tests/functional/builtins/codegen/test_abi_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def f(x: Bytes[32 * 3]):
w3.eth.send_transaction({"to": c.address, "data": data})


def test_abi_decode_oob_due_to_invalid_head(w3, tx_failed, get_contract):
def test_abi_decode_oob_due_to_large_inner_payload(w3, tx_failed, get_contract):
code = """
@external
def f(x: Bytes[32 * 5]):
Expand All @@ -517,3 +517,21 @@ def f(x: Bytes[32 * 5]):
data += (0x3).to_bytes(32, "big") * 4
with tx_failed():
w3.eth.send_transaction({"to": c.address, "data": data})


def test_abi_decode_oob_due_to_invalid_head(tx_failed, get_contract):
code = """
@external
def bar() -> (uint256, uint256, uint256):
return (480, 0, 0)
interface A:
def bar() -> String[32]: nonpayable
@external
def foo():
x:String[32] = extcall A(self).bar()
"""
c = get_contract(code)
with tx_failed():
c.foo()
2 changes: 1 addition & 1 deletion vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
add_ofst,
bytes_data_ptr,
calculate_type_for_external_return,
check_buffer_overflow_ir,
check_external_call,
clamp,
clamp2,
Expand All @@ -32,7 +33,6 @@
sar,
shl,
shr,
check_buffer_overflow_ir,
unwrap_location,
)
from vyper.codegen.expr import Expr
Expand Down

0 comments on commit 2095d29

Please sign in to comment.