Skip to content

Commit

Permalink
Add unit tests for name and symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Nov 21, 2023
1 parent 358e577 commit b7a52a3
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions tests/test_token.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,55 @@
import brownie
from brownie import *
from .fixtures import token

from .fixtures import token, staking, rewards

def test_name(token):
assert token.name() == "Origin DeFi Governance"


def test_symbol(token):
assert token.symbol() == "OGV"

def test_staking_name(staking):
assert staking.name() == "Vote Escrowed Origin DeFi Governance"

def test_staking_symbol(staking):
assert staking.name() == "veOGV"

def test_decimals(token):
assert token.decimals() == 18


def test_initial_total_supply(token):
assert token.totalSupply() == 1000000000 * 10**18


def test_owner(token):
assert token.owner() == accounts[0]


def test_transfer_ownership(token):
token.transferOwnership(accounts[1])
assert token.owner() == accounts[1]


def test_non_owner_cant_mint(token):
with brownie.reverts(
"AccessControl: account "+accounts[1].address.lower()+" is missing role 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6"
):
token.mint(accounts[1], 100, {"from": accounts[1]})


def test_minter_can_mint(token):
token.grantMinterRole(accounts[0], {"from": accounts[0]})
token.mint(accounts[1], 100, {"from": accounts[0]})
assert token.totalSupply() == 1000000000 * 10**18 + 100


def test_cant_upgrade_to_non_uups(token):
non_uups_token = NonUUPSToken.deploy({"from": accounts[0]})
with brownie.reverts("ERC1967Upgrade: new implementation is not UUPS"):
token.upgradeTo(non_uups_token.address)


def test_upgrade(token):
upgrade_to = TestToken.deploy({"from": accounts[0]})
token.upgradeTo(upgrade_to.address)
token = Contract.from_abi("TestToken", token.address, upgrade_to.abi)
with brownie.reverts("Upgraded"):
token.proof()


def test_non_owner_cant_upgrade(token):
upgrade_to = TestToken.deploy({"from": accounts[0]})
with brownie.reverts("Ownable: caller is not the owner"):
Expand All @@ -69,7 +64,7 @@ def test_burn_from(token):
alice = accounts[0]
bob = accounts[1]

before_balance = token.balanceOf(alice);
before_balance = token.balanceOf(alice)
token.approve(bob, 100, {'from': alice})
token.burnFrom(alice, 100, {'from': bob})
assert before_balance - 100 == token.balanceOf(alice)
Expand All @@ -78,7 +73,7 @@ def test_burn_from_fail_not_approved(token):
alice = accounts[0]
bob = accounts[1]

before_balance = token.balanceOf(alice);
before_balance = token.balanceOf(alice)
token.approve(bob, 90, {'from': alice})
with brownie.reverts("ERC20: insufficient allowance"):
token.burnFrom(alice, 100, {'from': bob})

0 comments on commit b7a52a3

Please sign in to comment.