Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Mar 7, 2024
1 parent 792a5a5 commit 3a4b4dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
10 changes: 2 additions & 8 deletions tests/functional/builtins/codegen/test_create_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,10 @@ def test2(target: address, salt: bytes32) -> address:

# can't create2 where contract already exists
if revert_on_failure is False:
assert not c.test2(c.address, salt, transact={})
assert not c.test2(c.address, salt)
else:
with tx_failed():
c.test2(c.address, salt, transact={})

# test single byte contract
# test2 = c.test2(b"\x01", salt)
# assert HexBytes(test2) == create2_address_of(c.address, salt, vyper_initcode(b"\x01"))
# with tx_failed():
# c.test2(bytecode, salt)
c.test2(c.address, salt)


# XXX: these various tests to check the msize allocator for
Expand Down
10 changes: 5 additions & 5 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ def build_IR(self, expr, context):

# create helper functions
# generates CREATE op sequence + zero check for result
def _create_ir(value, buf, length, salt, checked=True):
def _create_ir(value, buf, length, salt, revert_on_failure=True):
args = [value, buf, length]
create_op = "create"
if salt is not CREATE2_SENTINEL:
Expand All @@ -1595,7 +1595,7 @@ def _create_ir(value, buf, length, salt, checked=True):
["seq", eval_once_check(_freshname("create_builtin")), [create_op, *args]]
)

if not checked:
if not revert_on_failure:
return ret

ret = clamp_nonzero(ret)
Expand Down Expand Up @@ -1758,7 +1758,7 @@ def _build_create_IR(self, expr, args, context, value, salt, revert_on_failure):
["mstore", buf, forwarder_preamble],
["mstore", ["add", buf, preamble_length], aligned_target],
["mstore", ["add", buf, preamble_length + 20], forwarder_post],
_create_ir(value, buf, buf_len, salt=salt, checked=revert_on_failure),
_create_ir(value, buf, buf_len, salt, revert_on_failure),
]


Expand Down Expand Up @@ -1821,7 +1821,7 @@ def _build_create_IR(self, expr, args, context, value, salt, revert_on_failure):
buf = add_ofst(mem_ofst, 32 - preamble_len)
buf_len = ["add", codesize, preamble_len]

ir.append(_create_ir(value, buf, buf_len, salt, checked=revert_on_failure))
ir.append(_create_ir(value, buf, buf_len, salt, revert_on_failure))

return b1.resolve(b2.resolve(ir))

Expand Down Expand Up @@ -1922,7 +1922,7 @@ def _build_create_IR(

length = ["add", codesize, encoded_args_len]

ir.append(_create_ir(value, mem_ofst, length, salt, checked=revert_on_failure))
ir.append(_create_ir(value, mem_ofst, length, salt, revert_on_failure))

return b1.resolve(b2.resolve(ir))

Expand Down

0 comments on commit 3a4b4dd

Please sign in to comment.