From 1184de1c50c08121755131af2452d207df39751e Mon Sep 17 00:00:00 2001 From: nolash Date: Sat, 6 Feb 2021 05:43:56 +0100 Subject: [PATCH] Do not set participation on spends to self, introduce minimum spend --- python/tests/test_pure.py | 1 - python/tests/test_redistribution.py | 6 ++++-- solidity/RedistributedDemurrageToken.sol | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/tests/test_pure.py b/python/tests/test_pure.py index 51bc87b..6ad7201 100644 --- a/python/tests/test_pure.py +++ b/python/tests/test_pure.py @@ -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(); diff --git a/python/tests/test_redistribution.py b/python/tests/test_redistribution.py index fe9c097..219fa07 100644 --- a/python/tests/test_redistribution.py +++ b/python/tests/test_redistribution.py @@ -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(); diff --git a/solidity/RedistributedDemurrageToken.sol b/solidity/RedistributedDemurrageToken.sol index 87519da..74a3e50 100644 --- a/solidity/RedistributedDemurrageToken.sol +++ b/solidity/RedistributedDemurrageToken.sol @@ -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;