From 2f5bb63f9af07a3a61a745a51185793237c9e916 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 6 Jun 2021 06:01:35 +0200 Subject: [PATCH] Use chain string in sim constructor --- python/erc20_demurrage_token/sim/sim.py | 7 ++++--- python/tests/sim/tests_sim.py | 6 +----- python/tests/sim/tests_sim_limit.py | 6 +----- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/python/erc20_demurrage_token/sim/sim.py b/python/erc20_demurrage_token/sim/sim.py index 89610c7..d689e95 100644 --- a/python/erc20_demurrage_token/sim/sim.py +++ b/python/erc20_demurrage_token/sim/sim.py @@ -2,6 +2,7 @@ import logging # external imports +from chainlib.chain import ChainSpec from chainlib.eth.unittest.ethtester import create_tester_signer from chainlib.eth.unittest.base import TestRPCConnection from chainlib.eth.tx import ( @@ -35,8 +36,8 @@ logg = logging.getLogger(__name__) class DemurrageTokenSimulation: - def __init__(self, chain_spec, settings, redistribute=True, cap=0, actors=1): - self.chain_spec = chain_spec + def __init__(self, chain_str, settings, redistribute=True, cap=0, actors=1): + self.chain_spec = ChainSpec.from_chain_str(chain_str) self.accounts = [] self.keystore = DictKeystore() self.signer = EIP155Signer(self.keystore) @@ -76,7 +77,7 @@ class DemurrageTokenSimulation: self.start_timestamp = self.last_timestamp nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.rpc) - c = DemurrageToken(chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) (tx_hash, o) = c.constructor(self.accounts[0], settings, redistribute=redistribute, cap=cap) self.rpc.do(o) o = receipt(tx_hash) diff --git a/python/tests/sim/tests_sim.py b/python/tests/sim/tests_sim.py index 1ff19ea..1f354d2 100644 --- a/python/tests/sim/tests_sim.py +++ b/python/tests/sim/tests_sim.py @@ -2,9 +2,6 @@ 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 @@ -16,7 +13,6 @@ logg = logging.getLogger() class TestSim(unittest.TestCase): def setUp(self): - self.chain_spec = ChainSpec('evm', 'foochain', 42) self.cap = 0 settings = DemurrageTokenSettings() settings.name = 'Simulated Demurrage Token' @@ -24,7 +20,7 @@ class TestSim(unittest.TestCase): settings.decimals = 6 settings.demurrage_level = 5010590837337300000000000000000000 # equals approx 2% per month settings.period_minutes = 10800 # 1 week in minutes - self.sim = DemurrageTokenSimulation(self.chain_spec, settings, redistribute=True, cap=self.cap, actors=10) + self.sim = DemurrageTokenSimulation('evm:foochain:42', settings, redistribute=True, cap=self.cap, actors=10) def test_mint(self): diff --git a/python/tests/sim/tests_sim_limit.py b/python/tests/sim/tests_sim_limit.py index bb53b30..ea3bfae 100644 --- a/python/tests/sim/tests_sim_limit.py +++ b/python/tests/sim/tests_sim_limit.py @@ -2,9 +2,6 @@ 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 ( @@ -18,7 +15,6 @@ logg = logging.getLogger() class TestLimit(unittest.TestCase): def setUp(self): - self.chain_spec = ChainSpec('evm', 'foochain', 42) self.cap = 0 settings = DemurrageTokenSettings() settings.name = 'Simulated Demurrage Token' @@ -26,7 +22,7 @@ class TestLimit(unittest.TestCase): settings.decimals = 6 settings.demurrage_level = 1 settings.period_minutes = 1 - self.sim = DemurrageTokenSimulation(self.chain_spec, settings, redistribute=True, cap=self.cap, actors=1) + self.sim = DemurrageTokenSimulation('evm:foochain:42', settings, redistribute=True, cap=self.cap, actors=1) def test_limit(self):