From b09a6f41667db60008b8d78e81af6707317530a8 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 6 Jun 2021 10:09:26 +0200 Subject: [PATCH] Fix script bug cap --- python/examples/sim.py | 2 +- python/tests/test_redistribution.py | 41 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/python/examples/sim.py b/python/examples/sim.py index 7d86ae4..a82eb45 100644 --- a/python/examples/sim.py +++ b/python/examples/sim.py @@ -18,7 +18,7 @@ settings.decimals = 6 settings.demurrage_level = int(decay_per_minute*(10**40)) settings.period_minutes = 10800 # 1 week in minutes chain = 'evm:foochain:42' -cap = sim.from_units(10 ** 12) # 1 tn token units, with 6 decimal places +cap = (10 ** 6) * (10 ** 12) # instantiate simulation sim = DemurrageTokenSimulation(chain, settings, redistribute=True, cap=cap, actors=10) diff --git a/python/tests/test_redistribution.py b/python/tests/test_redistribution.py index eed04a9..f39aaaf 100644 --- a/python/tests/test_redistribution.py +++ b/python/tests/test_redistribution.py @@ -28,6 +28,47 @@ testdir = os.path.dirname(__file__) class TestRedistribution(TestDemurrageDefault): + def test_whole_is_parts(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 100000000) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], 100000000) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc) + c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[3], 50000000) + r = self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + self.backend.time_travel(self.start_time + self.period_seconds + 1) + + (tx_hash, o) = c.change_period(self.address, self.accounts[1]) + r = self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + balance = 0 + for i in range(3): + o = c.balance_of(self.accounts[i+1]) + r = self.rpc.do(o) + balance += c.parse_balance_of(r) + + self.assertEqual(balance, 200000000) + + def test_debug_periods(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc) c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)