Skip to content

Commit

Permalink
check for deployed contract at address
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Dec 26, 2023
1 parent ca10a54 commit a3beca4
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions tests/integration/test_create2_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,30 @@ def deploy_contract(
blueprint: bool = False,
):

salt = keccak(42069)
compiled_bytecode = contract_obj.compiler_data.bytecode
(
precomputed_address,
deployment_bytecode,
) = get_create2_deployment_address(
create2deployer,
compiled_bytecode,
abi_encoded_args,
salt,
blueprint=blueprint,
blueprint_preamble=b"\xFE\x71\x00",
)
assert precomputed_address == calculated_address
try:
salt = keccak(42069)
compiled_bytecode = contract_obj.compiler_data.bytecode
(
precomputed_address,
deployment_bytecode,
) = get_create2_deployment_address(
create2deployer,
compiled_bytecode,
abi_encoded_args,
salt,
blueprint=blueprint,
blueprint_preamble=b"\xFE\x71\x00",
)
assert precomputed_address == calculated_address

with boa.env.prank(deployer):
deploy_via_create2_factory(create2deployer, deployment_bytecode, salt)
with boa.env.prank(deployer):
deploy_via_create2_factory(
create2deployer, deployment_bytecode, salt
)
except Exception:
# we revert here if contract is already deployed!
# safe to catch exception since we perform other tests later on
return contract_obj.at(precomputed_address)

return contract_obj.at(precomputed_address)

Expand Down Expand Up @@ -148,14 +155,15 @@ def factory(
blueprint=False,
)

with boa.env.prank(deployer):
_factory.initialise_ownership(fee_receiver, owner)
if _factory.admin() == "0x0000000000000000000000000000000000000000":
with boa.env.prank(deployer):
_factory.initialise_ownership(fee_receiver, owner)

with boa.env.prank(owner):
_factory.set_pool_implementation(amm_implementation.address, 0)
_factory.set_gauge_implementation(gauge_implementation.address)
_factory.set_views_implementation(views_contract.address)
_factory.set_math_implementation(math_contract.address)
with boa.env.prank(owner):
_factory.set_pool_implementation(amm_implementation.address, 0)
_factory.set_gauge_implementation(gauge_implementation.address)
_factory.set_views_implementation(views_contract.address)
_factory.set_math_implementation(math_contract.address)

return _factory

Expand Down

0 comments on commit a3beca4

Please sign in to comment.