Skip to content

Commit

Permalink
Fix exception match texts
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Mar 20, 2024
1 parent fa6e1ec commit fdedb3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
26 changes: 10 additions & 16 deletions eth_defi/enzyme/generic_adapter_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,17 @@ def deploy_vault_with_generic_adapter(

# Log EtherScan API key
# Nothing bad can be done with this key, but good diagnostics is more important
web3 = deployment.web3
deployed_at_block = web3.eth.block_number
logger.info(
"Deploying Enzyme vault. Enzyme fund deployer: %s, Terms of service: %s, USDC: %s, Etherscan API key: %s",
"Deploying Enzyme vault. Enzyme fund deployer: %s, Terms of service: %s, USDC: %s, Etherscan API key: %s, block %d",
deployment.contracts.fund_deployer.address,
terms_of_service.address if terms_of_service is not None else "-",
denomination_asset.address,
etherscan_api_key,
deployed_at_block,
)

web3 = deployment.web3

deployed_at_block = web3.eth.block_number

if not mock_guard:
guard, tx_hash = deploy_contract_with_forge(
web3,
Expand All @@ -165,14 +164,6 @@ def deploy_vault_with_generic_adapter(
)
logger.info("MockGuard is %s deployed at %s", guard.address, tx_hash.hex())

# generic_adapter = deploy_contract(
# web3,
# f"GuardedGenericAdapter.json",
# deployer,
# deployment.contracts.integration_manager.address,
# guard.address,
# )

generic_adapter, tx_hash = deploy_contract_with_forge(
web3,
CONTRACTS_ROOT / "in-house",
Expand Down Expand Up @@ -240,12 +231,17 @@ def deploy_vault_with_generic_adapter(
# When swap is performed, the tokens will land on the integration contract
# and this contract must be listed as the receiver.
# Enzyme will then internally move tokens to its vault from here.
guard.functions.allowReceiver(generic_adapter.address, "").transact({"from": deployer.address})
tx_hash = guard.functions.allowReceiver(generic_adapter.address, "").transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)

# Because Enzyme does not pass the asset manager address to through integration manager,
# we set the vault address itself as asset manager for the guard
tx_hash = guard.functions.allowSender(vault.address, "").transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)
else:
# Production deployment foobar - add this warning message for now until figuring
# out why allowReceiver() failed
logger.warning("No receiver whitelisted")

# Give generic adapter back reference to the vault
assert vault.functions.getCreator().call() != ZERO_ADDRESS, f"Bad vault creator {vault.functions.getCreator().call()}"
Expand All @@ -256,8 +252,6 @@ def deploy_vault_with_generic_adapter(
).transact({"from": deployer.address})
assert_transaction_success_with_explanation(web3, tx_hash)

receipt = web3.eth.get_transaction_receipt(tx_hash)

assert generic_adapter.functions.getIntegrationManager().call() == deployment.contracts.integration_manager.address
assert comptroller.functions.getDenominationAsset().call() == denomination_asset.address
assert vault.functions.getTrackedAssets().call() == [denomination_asset.address]
Expand Down
8 changes: 4 additions & 4 deletions tests/guard/test_guard_simple_vault_uniswap_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_guard_pair_not_approved(
FOREVER_DEADLINE,
)

with pytest.raises(TransactionFailed, match="execution reverted: Token not allowed"):
with pytest.raises(TransactionFailed, match="Token not allowed"):
target, call_data = encode_simple_vault_transaction(trade_call)
vault.functions.performCall(target, call_data).transact({"from": asset_manager})

Expand Down Expand Up @@ -393,7 +393,7 @@ def test_guard_unauthorized_withdraw(
usdc_amount,
)

with pytest.raises(TransactionFailed, match="execution reverted: Receiver address does not match"):
with pytest.raises(TransactionFailed, match="Receiver address"):
target, call_data = encode_simple_vault_transaction(transfer_call)
vault.functions.performCall(target, call_data).transact({"from": asset_manager})

Expand All @@ -416,7 +416,7 @@ def test_guard_unauthorized_approve(
usdc_amount,
)

with pytest.raises(TransactionFailed, match="execution reverted: Approve address does not match"):
with pytest.raises(TransactionFailed, match="Approve address"):
target, call_data = encode_simple_vault_transaction(transfer_call)
vault.functions.performCall(target, call_data).transact({"from": asset_manager})

Expand Down Expand Up @@ -455,6 +455,6 @@ def test_guard_third_party_trade(
FOREVER_DEADLINE,
)

with pytest.raises(TransactionFailed, match="execution reverted: Sender not allowed"):
with pytest.raises(TransactionFailed, match="Sender not allowed"):
target, call_data = encode_simple_vault_transaction(trade_call)
vault.functions.performCall(target, call_data).transact({"from": third_party})

0 comments on commit fdedb3f

Please sign in to comment.