Started adding ERC20 tests

pull/7/head
Neeraj Kashyap 2021-12-17 17:22:55 -08:00
rodzic 07f6217ddd
commit f12f0de623
2 zmienionych plików z 46 dodań i 2 usunięć

Wyświetl plik

@ -2,7 +2,9 @@ import unittest
from brownie import accounts, network
from dao.core import gogogo
from .core import facet_cut, gogogo
from .ERC20Facet import ERC20Facet
from .ERC20Initializer import ERC20Initializer
class MoonstreamDAOTestCase(unittest.TestCase):
@ -15,6 +17,32 @@ class MoonstreamDAOTestCase(unittest.TestCase):
cls.contracts = gogogo(accounts[0], {"from": accounts[0]})
class MoonstreamDAOFullTestCase(MoonstreamDAOTestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
# Deploy ERC20
initializer = ERC20Initializer(None)
initializer.deploy({"from": accounts[0]})
erc20_facet = ERC20Facet(None)
erc20_facet.deploy({"from": accounts[0]})
diamond_address = cls.contracts["Diamond"]
facet_cut(
diamond_address,
"ERC20Facet",
erc20_facet.address,
"add",
{"from": accounts[0]},
initializer.address,
)
cls.erc20_initializer = initializer.address
cls.erc20_facet = erc20_facet.address
class TestCoreDeployment(MoonstreamDAOTestCase):
def test_gogogo(self):
self.assertIn("DiamondCutFacet", self.contracts)

Wyświetl plik

@ -2,7 +2,7 @@ from brownie import accounts
from . import ERC20Facet, ERC20Initializer
from .core import ZERO_ADDRESS, facet_cut
from .test_core import MoonstreamDAOTestCase
from .test_core import MoonstreamDAOTestCase, MoonstreamDAOFullTestCase
class TestDeployment(MoonstreamDAOTestCase):
@ -113,3 +113,19 @@ class TestRemoveFacet(MoonstreamDAOTestCase):
with self.assertRaises(Exception):
symbol = diamond_erc20.symbol()
class TestERC20(MoonstreamDAOFullTestCase):
def test_mint_fails_if_not_controller(self):
diamond_address = self.contracts["Diamond"]
diamond = ERC20Facet.ERC20Facet(diamond_address)
with self.assertRaises(Exception):
diamond.mint(accounts[1].address, 1000, {"from": accounts[1]})
def test_mint_to_another_address(self):
diamond_address = self.contracts["Diamond"]
diamond = ERC20Facet.ERC20Facet(diamond_address)
initial_balance = diamond.balance_of(accounts[1].address)
diamond.mint(accounts[1].address, 1000, {"from": accounts[0]})
final_balance = diamond.balance_of(accounts[1].address)
self.assertEqual(final_balance, initial_balance + 1000)