Rehabilitate redistribution unit
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .token import (
|
||||
DemurrageToken,
|
||||
DemurrageTokenSettings,
|
||||
DemurrageRedistribution,
|
||||
)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -306,18 +306,18 @@ class DemurrageToken(ERC20):
|
||||
return o
|
||||
|
||||
|
||||
def to_redistribution(self, contract_address, participants, demurrage_modifier_ppm, value, period, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
def to_redistribution(self, contract_address, participants, demurrage_modifier, value, period, sender_address=ZERO_ADDRESS, id_generator=None):
|
||||
j = JSONRPCRequest(id_generator)
|
||||
o = j.template()
|
||||
o['method'] = 'eth_call'
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('toRedistribution')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.typ_literal('int128')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.uint256(participants)
|
||||
enc.uint256(demurrage_modifier_ppm)
|
||||
enc.uint256(demurrage_modifier)
|
||||
enc.uint256(value)
|
||||
enc.uint256(period)
|
||||
data = add_0x(enc.get())
|
||||
@@ -536,7 +536,7 @@ class DemurrageToken(ERC20):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('getDistribution')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.typ_literal('int128')
|
||||
enc.uint256(supply)
|
||||
enc.uint256(demurrage_amount)
|
||||
data = add_0x(enc.get())
|
||||
@@ -555,7 +555,7 @@ class DemurrageToken(ERC20):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('getDistributionFromRedistribution')
|
||||
v = strip_0x(redistribution)
|
||||
enc.typ_literal('(uint32,uint72,uint104)')
|
||||
enc.typ_literal('(uint32,uint72,uint64)')
|
||||
enc.bytes32(v[:64])
|
||||
enc.bytes32(v[64:128])
|
||||
enc.bytes32(v[128:192])
|
||||
|
||||
@@ -114,6 +114,17 @@ class TestDemurrage(EthTesterCase):
|
||||
logg.debug('contract address {} start block {} start time {}'.format(self.address, self.start_block, self.start_time))
|
||||
|
||||
|
||||
def assert_within(self, v, target, tolerance_ppm):
|
||||
lower_target = target - (target * (tolerance_ppm / 1000000))
|
||||
higher_target = target + (target * (tolerance_ppm / 1000000))
|
||||
#self.assertGreaterEqual(v, lower_target)
|
||||
#self.assertLessEqual(v, higher_target)
|
||||
if v >= lower_target and v <= higher_target:
|
||||
logg.debug('asserted within {} <= {} <= {}'.format(lower_target, v, higher_target))
|
||||
return
|
||||
raise AssertionError('{} not within lower {} and higher {}'.format(v, lower_target, higher_target))
|
||||
|
||||
|
||||
def assert_within_lower(self, v, target, tolerance_ppm):
|
||||
lower_target = target - (target * (tolerance_ppm / 1000000))
|
||||
self.assertGreaterEqual(v, lower_target)
|
||||
|
||||
Reference in New Issue
Block a user