Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions tests/functional/builtins/codegen/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def test_concat_buffer2(get_contract):

@deploy
def __init__():
i = -1
self.i = -1
s: String[2] = concat("a", "b")

@external
def foo() -> int256:
return i
return self.i
"""
c = get_contract(code)
assert c.foo() == -1
Expand Down
12 changes: 6 additions & 6 deletions tests/functional/builtins/codegen/test_create_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ def test_create_from_blueprint_bad_code_offset(

@deploy
def __init__(blueprint_address: address):
BLUEPRINT = blueprint_address
self.BLUEPRINT = blueprint_address

@external
def test(code_ofst: uint256) -> address:
return create_from_blueprint(BLUEPRINT, code_offset=code_ofst)
return create_from_blueprint(self.BLUEPRINT, code_offset=code_ofst)
"""

initcode_len = 100
Expand Down Expand Up @@ -341,16 +341,16 @@ def test_create_from_blueprint_args(

@deploy
def __init__(foo: String[128], bar: Bar):
FOO = foo
BAR = bar
self.FOO = foo
self.BAR = bar

@external
def foo() -> String[128]:
return FOO
return self.FOO

@external
def bar() -> Bar:
return BAR
return self.BAR
"""

deployer_code = """
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/builtins/codegen/test_ecrecover.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def test_invalid_signature2(get_contract):

@deploy
def __init__():
owner = 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf
self.owner = 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf

@internal
def get_v() -> uint256:
assert owner == owner # force a dload to write at index 0 of memory
assert self.owner == self.owner # force a dload to write at index 0 of memory
return 21

@payable
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/builtins/codegen/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def test_slice_immutable(

@deploy
def __init__(inp: Bytes[{length_bound}], start: uint256, length: uint256):
IMMUTABLE_BYTES = inp
IMMUTABLE_SLICE = slice(IMMUTABLE_BYTES, {_start}, {_length})
self.IMMUTABLE_BYTES = inp
self.IMMUTABLE_SLICE = slice(self.IMMUTABLE_BYTES, {_start}, {_length})

@external
def do_splice() -> Bytes[{length_bound}]:
return IMMUTABLE_SLICE
return self.IMMUTABLE_SLICE
"""

def _get_contract():
Expand Down Expand Up @@ -185,10 +185,10 @@ def test_slice_bytes_fuzz(
IMMUTABLE_BYTES: immutable(Bytes[{length_bound}])
@deploy
def __init__(foo: Bytes[{length_bound}]):
IMMUTABLE_BYTES = foo
self.IMMUTABLE_BYTES = foo
"""
spliced_code = ""
foo = "IMMUTABLE_BYTES"
foo = "self.IMMUTABLE_BYTES"
elif location == "literal":
spliced_code = ""
foo = f"{bytesdata}"
Expand Down Expand Up @@ -315,11 +315,11 @@ def test_slice_immutable_length_arg(get_contract):

@deploy
def __init__():
LENGTH = 5
self.LENGTH = 5

@external
def do_slice(inp: Bytes[50]) -> Bytes[50]:
return slice(inp, 0, LENGTH)
return slice(inp, 0, self.LENGTH)
"""
c = get_contract(code)
x = c.do_slice(b"abcdefghijklmnopqrstuvwxyz1234")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_returning_immutables(get_contract):

@deploy
def __init__():
a = 5
self.a = 5

@internal
def get_my_immutable() -> uint256:
return a
return self.a

@external
def get_immutable() -> uint256:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def test_pragma_with_immutables_and_constants(make_input_bundle, get_contract, t

@deploy
def __init__():
b = 666
self.b = 666

"""
main = """
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/codegen/features/decorators/test_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ def test_invalid_immutable_access():

@deploy
def __init__():
COUNTER = 1234
self.COUNTER = 1234

@pure
@external
def foo() -> uint256:
return COUNTER
return self.COUNTER
"""
with pytest.raises(StateAccessViolation):
compile_code(code)
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_invalid_module_immutable_access(make_input_bundle):

@deploy
def __init__():
COUNTER = 123
self.COUNTER = 123
"""
code = """
import lib1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def foo() -> Bytes[32]:

# test raw_return from storage, transient, constant and immutable
# calldata Bytes[..] need clamp and thus are internally coppied to memory
@pytest.mark.parametrize("to_ret", ["self.s", "self.t", "c", "i"])
@pytest.mark.parametrize("to_ret", ["self.s", "self.t", "c", "self.i"])
def test_raw_return_from_location(env, get_contract, to_ret):
has_transient = version_check(begin="cancun")
if to_ret == "self.t" and not has_transient:
Expand All @@ -219,7 +219,7 @@ def test_raw_return_from_location(env, get_contract, to_ret):
@deploy
def __init__():
self.s = b'cow'
i = b'cow'
self.i = b'cow'

@external
@raw_return
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/codegen/features/test_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_long_call_chain_in_ctor(get_contract):

@deploy
def __init__(i: uint256):
x = self.foo0(i)
self.x = self.foo0(i)
"""
for i in range(16):
code += f"""
Expand Down Expand Up @@ -291,9 +291,9 @@ def test_immutable_set_with_constants(get_contract):

@deploy
def __init__():
I_UINT = CONST_UINT
I_ADDR = CONST_ADDR
I_BYTES32 = CONST_BYTES32
self.I_UINT = CONST_UINT
self.I_ADDR = CONST_ADDR
self.I_BYTES32 = CONST_BYTES32
"""
print(code)
c = get_contract(code)
Expand Down
Loading
Loading