Skip to content

Commit

Permalink
fix: fix yearn#179 (yearn#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffel authored and orbxball committed Mar 22, 2021
1 parent fc4eb36 commit cb87ffe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion contracts/Registry.vy
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def newRelease(vault: address):
assert Vault(vault).governance() == msg.sender # dev: not governed

self._registerRelease(vault)
self._registerDeployment(Vault(vault).token(), vault) # NOTE: Should never throw


@internal
Expand Down
1 change: 1 addition & 0 deletions tests/functional/registry/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_deployment_management(
# Creating the first deployment makes `latestVault()` work
v1_vault = create_vault(token, version="1.0.0")
registry.newRelease(v1_vault, {"from": gov})
registry.endorseVault(v1_vault, {"from": gov})
assert registry.latestVault(token) == v1_vault
assert registry.latestRelease() == v1_vault.apiVersion() == "1.0.0"

Expand Down
6 changes: 6 additions & 0 deletions tests/functional/wrappers/test_affliate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_config(gov, token, vault, registry, affiliate_token):

# Now they work when we have a Vault
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
assert affiliate_token.bestVault() == vault
assert affiliate_token.allVaults() == [vault]

Expand Down Expand Up @@ -62,6 +63,7 @@ def test_setRegistry(rando, affiliate, gov, affiliate_token):

def test_deposit(token, registry, vault, affiliate_token, gov, rando):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
assert affiliate_token.balanceOf(rando) == vault.balanceOf(rando) == 0

Expand All @@ -75,6 +77,7 @@ def test_deposit(token, registry, vault, affiliate_token, gov, rando):
def test_migrate(token, registry, create_vault, affiliate_token, gov, rando, affiliate):
vault1 = create_vault(version="1.0.0", token=token)
registry.newRelease(vault1, {"from": gov})
registry.endorseVault(vault1, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
token.approve(affiliate_token, 10000, {"from": rando})
affiliate_token.deposit(10000, {"from": rando})
Expand All @@ -83,6 +86,7 @@ def test_migrate(token, registry, create_vault, affiliate_token, gov, rando, aff

vault2 = create_vault(version="2.0.0", token=token)
registry.newRelease(vault2, {"from": gov})
registry.endorseVault(vault2, {"from": gov})

with brownie.reverts():
affiliate_token.migrate({"from": rando})
Expand All @@ -96,6 +100,7 @@ def test_migrate(token, registry, create_vault, affiliate_token, gov, rando, aff

def test_transfer(token, registry, vault, affiliate_token, gov, rando, affiliate):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
token.approve(affiliate_token, 10000, {"from": rando})
affiliate_token.deposit(10000, {"from": rando})
Expand All @@ -109,6 +114,7 @@ def test_transfer(token, registry, vault, affiliate_token, gov, rando, affiliate

def test_withdraw(token, registry, vault, affiliate_token, gov, rando):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
token.approve(affiliate_token, 10000, {"from": rando})
affiliate_token.deposit(10000, {"from": rando})
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/wrappers/test_ytoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_config(gov, token, vault, registry, ytoken):

# Now they work when we have a Vault
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
assert ytoken.bestVault() == vault
assert ytoken.name() == vault.name()
assert ytoken.symbol() == vault.symbol()
Expand All @@ -43,6 +44,7 @@ def test_setRegistry(rando, gov, ytoken):

def test_deposit(token, registry, vault, ytoken, gov, rando):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
assert ytoken.balanceOf(rando) == vault.balanceOf(rando) == 0

Expand All @@ -54,6 +56,7 @@ def test_deposit(token, registry, vault, ytoken, gov, rando):

def test_transfer(token, registry, vault, ytoken, gov, rando, affiliate):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
token.approve(ytoken, 10000, {"from": rando})
ytoken.deposit(10000, {"from": rando})
Expand All @@ -69,6 +72,7 @@ def test_transfer(token, registry, vault, ytoken, gov, rando, affiliate):

def test_withdraw(token, registry, vault, ytoken, gov, rando):
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})
token.transfer(rando, 10000, {"from": gov})
token.approve(ytoken, 10000, {"from": rando})
ytoken.deposit(10000, {"from": rando})
Expand All @@ -87,13 +91,16 @@ def test_migrate(token, registry, create_vault, sign_vault_permit, ytoken, gov):

vault1 = create_vault(version="1.0.0", token=token)
registry.newRelease(vault1, {"from": gov})
registry.endorseVault(vault1, {"from": gov})

assert registry.latestVault(token) == vault1

ytoken.deposit(5000, {"from": rando.address})
assert vault1.balanceOf(rando.address) == 5000

vault2 = create_vault(version="2.0.0", token=token)
registry.newRelease(vault2, {"from": gov})
registry.endorseVault(vault2, {"from": gov})
assert registry.latestVault(token) == vault2

ytoken.deposit(5000, {"from": rando.address})
Expand All @@ -120,6 +127,7 @@ def test_migrate(token, registry, create_vault, sign_vault_permit, ytoken, gov):
def test_yweth_wrapper(gov, rando, registry, create_vault, weth, yWETH):
vault1 = create_vault(version="1.0.0", token=weth)
registry.newRelease(vault1, {"from": gov})
registry.endorseVault(vault1, {"from": gov})
assert registry.latestVault(weth) == vault1
yweth = yWETH.deploy(weth, registry, {"from": gov})
assert yweth.token() == weth
Expand All @@ -131,6 +139,7 @@ def test_yweth_wrapper(gov, rando, registry, create_vault, weth, yWETH):

vault2 = create_vault(version="2.0.0", token=weth)
registry.newRelease(vault2, {"from": gov})
registry.endorseVault(vault2, {"from": gov})
assert registry.latestVault(weth) == vault2

# Migrations work just fine
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def rule_new_release(self):
print(f" Registry.newRelease({vault})")

self.registry.newRelease(vault, {"from": self.gov})
self.registry.endorseVault(vault, {"from": self.gov})

# NOTE: yToken's are non-custodial, so you need to authorize them
if self.wrapper._name == "yToken":
Expand Down Expand Up @@ -105,6 +106,7 @@ def test_migration_wrapper(
# NOTE: Must start with at least one vault in registry (for token)
vault = create_vault(token=token, version="1.0.0")
registry.newRelease(vault, {"from": gov})
registry.endorseVault(vault, {"from": gov})

# NOTE: yToken's are non-custodial, so you need to authorize them
if wrapper._name == "yToken":
Expand Down

0 comments on commit cb87ffe

Please sign in to comment.