Do not set participation on spends to self, introduce minimum spend

This commit is contained in:
nolash 2021-02-06 05:43:56 +01:00
parent 0e1851f6f7
commit 1184de1c50
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 7 additions and 4 deletions

View File

@ -72,7 +72,6 @@ class Test(unittest.TestCase):
self.assertEqual(960400, a)
@unittest.skip('foo')
def test_fractional_state(self):
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
self.contract.functions.remainder(2, 1).call();

View File

@ -90,7 +90,6 @@ class Test(unittest.TestCase):
self.assertEqual(redistribution.hex(), '000000000000000000000000000000000000000000000f4a1000000000000002')
@unittest.skip('foo')
def test_redistribution_balance_on_zero_participants(self):
supply = 1000000000000
tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[1], supply).transact()
@ -232,6 +231,10 @@ class Test(unittest.TestCase):
tx_hash = self.contract.functions.transfer(self.w3.eth.accounts[6], 2000000).transact({'from': self.w3.eth.accounts[1]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
# No cheating!
tx_hash = self.contract.functions.transfer(self.w3.eth.accounts[2], 3000000).transact({'from': self.w3.eth.accounts[2]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
balance = self.contract.functions.balanceOf(self.w3.eth.accounts[0]).call()
self.assertEqual(balance, 0)
@ -248,7 +251,6 @@ class Test(unittest.TestCase):
r = self.w3.eth.getTransactionReceipt(tx_hash)
balance = self.contract.functions.balanceOf(self.w3.eth.accounts[0]).call()
#self.assertEqual(balance, 117600)
self.assertEqual(balance, int((z * 0.02 * 0.98) / 2))
redistribution = self.contract.functions.redistributions(1).call();

View File

@ -10,6 +10,7 @@ contract RedistributedDemurrageToken {
string public symbol;
uint256 public decimals;
uint256 public totalSupply;
uint256 public minimumParticipantSpend;
uint256 public periodStart;
uint256 public periodDuration;
@ -43,6 +44,7 @@ contract RedistributedDemurrageToken {
sinkAddress = _defaultSinkAddress;
bytes32 initialRedistribution = toRedistribution(0, 0, 1);
redistributions.push(initialRedistribution);
minimumParticipantSpend = 10 ** uint256(_decimals);
}
// Given address will be allowed to call the mintTo() function
@ -347,7 +349,7 @@ contract RedistributedDemurrageToken {
increaseBaseBalance(_to, _value);
period = actualPeriod();
if (_value > 0 && accountPeriod(_from) != period) {
if (_value >= minimumParticipantSpend && accountPeriod(_from) != period && _from != _to) {
registerAccountPeriod(_from, period);
}
return true;