erc20-demurrage-token/python/tests/sim/tests_sim.py

62 lines
1.7 KiB
Python
Raw Normal View History

2021-06-05 17:59:34 +02:00
# standard imports
import unittest
import logging
# external imports
from chainlib.chain import ChainSpec
# local imports
from erc20_demurrage_token import DemurrageTokenSettings
from erc20_demurrage_token.sim import DemurrageTokenSimulation
2021-06-05 20:23:06 +02:00
logging.basicConfig(level=logging.INFO)
2021-06-05 17:59:34 +02:00
logg = logging.getLogger()
class TestSim(unittest.TestCase):
def setUp(self):
self.chain_spec = ChainSpec('evm', 'foochain', 42)
2021-06-05 19:19:17 +02:00
#self.cap = 1000000000
self.cap = 0
2021-06-05 17:59:34 +02:00
settings = DemurrageTokenSettings()
settings.name = 'Simulated Demurrage Token'
settings.symbol = 'SIM'
settings.decimals = 6
settings.demurrage_level = 50
settings.period_minutes = 10800
2021-06-05 19:19:17 +02:00
self.sim = DemurrageTokenSimulation(self.chain_spec, settings, redistribute=True, cap=self.cap, actors=10)
2021-06-05 17:59:34 +02:00
2021-06-05 19:19:17 +02:00
def test_mint(self):
self.sim.mint(self.sim.actors[0], 1024)
self.sim.next()
balance = self.sim.balance(self.sim.actors[0])
self.assertEqual(balance, 1024)
def test_transfer(self):
self.sim.mint(self.sim.actors[0], 1024)
self.sim.transfer(self.sim.actors[0], self.sim.actors[1], 500)
self.sim.next()
2021-06-05 20:23:06 +02:00
balance = self.sim.balance(self.sim.actors[0])
self.assertEqual(balance, 524)
balance = self.sim.balance(self.sim.actors[1])
self.assertEqual(balance, 500)
def test_more_periods(self):
self.sim.mint(self.sim.actors[0], 1024)
self.sim.next()
self.sim.mint(self.sim.actors[0], 1024)
self.sim.next()
balance = self.sim.balance(self.sim.actors[0])
self.assertEqual(balance, 2048)
2021-06-05 19:19:17 +02:00
2021-06-05 17:59:34 +02:00
if __name__ == '__main__':
unittest.main()