From 3a4b4dd9f58f9726548c33735f0c3cea969e0be9 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Thu, 7 Mar 2024 18:13:13 +0100 Subject: [PATCH] Fix test --- .../builtins/codegen/test_create_functions.py | 10 ++-------- vyper/builtins/functions.py | 10 +++++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/functional/builtins/codegen/test_create_functions.py b/tests/functional/builtins/codegen/test_create_functions.py index bb2cda702e..ce832cd3cb 100644 --- a/tests/functional/builtins/codegen/test_create_functions.py +++ b/tests/functional/builtins/codegen/test_create_functions.py @@ -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 diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index de03ef88c0..a3a7267aa1 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -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: @@ -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) @@ -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), ] @@ -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)) @@ -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))