Skip to content

Commit

Permalink
fix/reinit (#8)
Browse files Browse the repository at this point in the history
* test: reinit bug

* fix: reinit bug
  • Loading branch information
banteg committed Sep 15, 2021
1 parent 1e2fd78 commit 980a3e4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/VestingEscrowFactory.vy
@@ -1,4 +1,4 @@
# @version 0.2.8
# @version 0.2.16
"""
@title Vesting Escrow Factory
@author Curve Finance, Yearn Finance
Expand Down
8 changes: 5 additions & 3 deletions contracts/VestingEscrowSimple.vy
@@ -1,4 +1,4 @@
# @version 0.2.8
# @version 0.2.16
"""
@title Simple Vesting Escrow
@author Curve Finance, Yearn Finance
Expand Down Expand Up @@ -35,14 +35,15 @@ cliff_length: public(uint256)
total_locked: public(uint256)
total_claimed: public(uint256)
disabled_at: public(uint256)
initialized: public(bool)

admin: public(address)
future_admin: public(address)

@external
def __init__():
# ensure that the original contract cannot be initialized
self.admin = msg.sender
self.initialized = True


@external
Expand All @@ -69,7 +70,8 @@ def initialize(
@param end_time Time until everything should be vested
@param cliff_length Duration after which the first portion vests
"""
assert self.admin == ZERO_ADDRESS # dev: can only initialize once
assert not self.initialized # dev: can only initialize once
self.initialized = True

self.token = ERC20(token)
self.admin = admin
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/ERC20.vy
Expand Up @@ -2,7 +2,7 @@
@notice Mock ERC20 for testing
"""

# @version 0.2.8
# @version 0.2.16

event Transfer:
_from: indexed(address)
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/VestingEscrow/test_init.py
@@ -0,0 +1,9 @@
import brownie


def test_reinit_impossible(vesting, accounts, token):
vesting.renounce_ownership({"from": accounts[0]})
with brownie.reverts("dev: can only initialize once"):
vesting.initialize(
accounts[1], token, accounts[1], 0, 0, 0, 0, {"from": accounts[1]}
)

0 comments on commit 980a3e4

Please sign in to comment.