Skip to content

Commit

Permalink
chore: add events
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Oct 28, 2024
1 parent 1bccce1 commit 1ff539b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 6 additions & 1 deletion contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ event RoleSet:
role: indexed(Roles)

# STORAGE MANAGEMENT EVENTS
event UpdateFutureRoleManager:
future_role_manager: indexed(address)

event UpdateRoleManager:
role_manager: indexed(address)

Expand Down Expand Up @@ -1577,6 +1580,8 @@ def transfer_role_manager(role_manager: address):
assert msg.sender == self.role_manager
self.future_role_manager = role_manager

log UpdateFutureRoleManager(role_manager)

@external
def accept_role_manager():
"""
Expand Down Expand Up @@ -1779,7 +1784,7 @@ def shutdown_vault():
new_roles: Roles = self.roles[msg.sender] | Roles.DEBT_MANAGER
self.roles[msg.sender] = new_roles
log RoleSet(msg.sender, new_roles)

log Shutdown()


Expand Down
6 changes: 5 additions & 1 deletion tests/unit/vault/test_emergency_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def test_shutdown(gov, panda, vault):
def test_shutdown_gives_debt_manager_role(gov, panda, vault):
vault.set_role(panda.address, ROLES.EMERGENCY_MANAGER, sender=gov)
assert ROLES.DEBT_MANAGER not in ROLES(vault.roles(panda))
vault.shutdown_vault(sender=panda)
tx = vault.shutdown_vault(sender=panda)
event = list(tx.decode_logs(vault.RoleSet))
assert len(event) == 1
assert event[0].account == panda.address
assert event[0].role == ROLES.DEBT_MANAGER | ROLES.EMERGENCY_MANAGER
assert ROLES.DEBT_MANAGER | ROLES.EMERGENCY_MANAGER == vault.roles(panda)


Expand Down
20 changes: 16 additions & 4 deletions tests/unit/vault/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def test_transfers_role_manager(vault, gov, strategist):
assert vault.role_manager() == gov
assert vault.future_role_manager() == ZERO_ADDRESS

vault.transfer_role_manager(strategist, sender=gov)
tx = vault.transfer_role_manager(strategist, sender=gov)
event = list(tx.decode_logs(vault.UpdateFutureRoleManager))
assert len(event) == 1
assert event[0].future_role_manager == strategist

assert vault.role_manager() == gov
assert vault.future_role_manager() == strategist
Expand All @@ -36,7 +39,10 @@ def test_gov_transfers_role_manager__gov_cant_accept(vault, gov, strategist):
assert vault.role_manager() == gov
assert vault.future_role_manager() == ZERO_ADDRESS

vault.transfer_role_manager(strategist, sender=gov)
tx = vault.transfer_role_manager(strategist, sender=gov)
event = list(tx.decode_logs(vault.UpdateFutureRoleManager))
assert len(event) == 1
assert event[0].future_role_manager == strategist

assert vault.role_manager() == gov
assert vault.future_role_manager() == strategist
Expand Down Expand Up @@ -65,12 +71,18 @@ def test_gov_transfers_role_manager__can_change_future_manager(
assert vault.role_manager() == gov
assert vault.future_role_manager() == ZERO_ADDRESS

vault.transfer_role_manager(strategist, sender=gov)
tx = vault.transfer_role_manager(strategist, sender=gov)
event = list(tx.decode_logs(vault.UpdateFutureRoleManager))
assert len(event) == 1
assert event[0].future_role_manager == strategist

assert vault.role_manager() == gov
assert vault.future_role_manager() == strategist

vault.transfer_role_manager(bunny, sender=gov)
tx = vault.transfer_role_manager(bunny, sender=gov)
event = list(tx.decode_logs(vault.UpdateFutureRoleManager))
assert len(event) == 1
assert event[0].future_role_manager == bunny

assert vault.role_manager() == gov
assert vault.future_role_manager() == bunny
Expand Down

0 comments on commit 1ff539b

Please sign in to comment.