Improve documentation, add mark constants, add removeMinter method

This commit is contained in:
nolash
2021-03-01 10:23:55 +01:00
parent 364731b220
commit aab0bc243c
9 changed files with 199 additions and 83 deletions

View File

@@ -111,7 +111,33 @@ class Test(unittest.TestCase):
balance = self.contract.functions.balanceOf(self.w3.eth.accounts[1]).call()
self.assertEqual(balance, int(2000 * 0.98))
def test_minter_control(self):
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[2], 1024).transact({'from': self.w3.eth.accounts[1]})
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
tx_hash = self.contract.functions.addMinter(self.w3.eth.accounts[1]).transact({'from': self.w3.eth.accounts[1]})
tx_hash = self.contract.functions.addMinter(self.w3.eth.accounts[1]).transact({'from': self.w3.eth.accounts[0]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
self.assertEqual(r.status, 1)
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
tx_hash = self.contract.functions.addMinter(self.w3.eth.accounts[2]).transact({'from': self.w3.eth.accounts[1]})
tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[2], 1024).transact({'from': self.w3.eth.accounts[1]})
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
tx_hash = self.contract.functions.addMinter(self.w3.eth.accounts[1]).transact({'from': self.w3.eth.accounts[2]})
tx_hash = self.contract.functions.removeMinter(self.w3.eth.accounts[1]).transact({'from': self.w3.eth.accounts[1]})
r = self.w3.eth.getTransactionReceipt(tx_hash)
self.assertEqual(r.status, 1)
with self.assertRaises(eth_tester.exceptions.TransactionFailed):
tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[2], 1024).transact({'from': self.w3.eth.accounts[1]})
def test_base_amount(self):
tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[1], 1000).transact()
r = self.w3.eth.getTransactionReceipt(tx_hash)

View File

@@ -60,20 +60,21 @@ class Test(unittest.TestCase):
pass
@unittest.skip('this function has been removed from contract')
def test_tax_period(self):
t = self.contract.functions.taxLevel().call()
logg.debug('taxlevel {}'.format(t))
a = self.contract.functions.toTaxPeriodAmount(1000000, 0).call()
a = self.contract.functions.toDemurrageAmount(1000000, 0).call()
self.assertEqual(a, 1000000)
a = self.contract.functions.toTaxPeriodAmount(1000000, 1).call()
a = self.contract.functions.toDemurrageAmount(1000000, 1).call()
self.assertEqual(a, 980000)
a = self.contract.functions.toTaxPeriodAmount(1000000, 2).call()
a = self.contract.functions.toDemurrageAmount(1000000, 2).call()
self.assertEqual(a, 960400)
a = self.contract.functions.toTaxPeriodAmount(980000, 1).call()
a = self.contract.functions.toDemurrageAmount(980000, 1).call()
self.assertEqual(a, 960400)

View File

@@ -71,6 +71,9 @@ class Test(unittest.TestCase):
# TODO: check receipt log outputs
def test_redistribution_storage(self):
redistribution = self.contract.functions.redistributions(0).call();
self.assertEqual(redistribution.hex(), '000000000000000000000000f424000000000000000000000000000000000001')
self.contract.functions.mintTo(self.w3.eth.accounts[1], 1000000).transact()
self.contract.functions.mintTo(self.w3.eth.accounts[2], 1000000).transact()