mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-22 08:16:47 +01:00
Complete refactor basic tests
This commit is contained in:
parent
32f536dec0
commit
4e4c0f1203
@ -25,7 +25,6 @@ testdir = os.path.dirname(__file__)
|
|||||||
|
|
||||||
class TestBasic(TestDemurrageDefault):
|
class TestBasic(TestDemurrageDefault):
|
||||||
|
|
||||||
@unittest.skip('foo')
|
|
||||||
def test_hello(self):
|
def test_hello(self):
|
||||||
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
@ -38,7 +37,6 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
r = self.rpc.do(o)
|
r = self.rpc.do(o)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skip('foo')
|
|
||||||
def test_apply_demurrage(self):
|
def test_apply_demurrage(self):
|
||||||
modifier = 10 * (10 ** 37)
|
modifier = 10 * (10 ** 37)
|
||||||
|
|
||||||
@ -66,7 +64,6 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
self.assertEqual(modifier, demurrage_amount)
|
self.assertEqual(modifier, demurrage_amount)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skip('foo')
|
|
||||||
def test_mint(self):
|
def test_mint(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -102,7 +99,6 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
self.assertEqual(balance, int(2000 * 0.98))
|
self.assertEqual(balance, int(2000 * 0.98))
|
||||||
|
|
||||||
|
|
||||||
@unittest.skip('foo')
|
|
||||||
def test_minter_control(self):
|
def test_minter_control(self):
|
||||||
|
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
@ -155,7 +151,6 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
self.assertEqual(r['status'], 0)
|
self.assertEqual(r['status'], 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_base_amount(self):
|
def test_base_amount(self):
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
@ -172,51 +167,77 @@ class TestBasic(TestDemurrageDefault):
|
|||||||
self.assertEqual(amount, 1020)
|
self.assertEqual(amount, 1020)
|
||||||
|
|
||||||
|
|
||||||
# def test_transfer(self):
|
def test_transfer(self):
|
||||||
# tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[1], 1024).transact()
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# self.assertEqual(r.status, 1)
|
|
||||||
#
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
# tx_hash = self.contract.functions.transfer(self.w3.eth.accounts[2], 500).transact({'from': self.w3.eth.accounts[1]})
|
self.rpc.do(o)
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
|
||||||
# self.assertEqual(r.status, 1)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
# logg.debug('tx {}'.format(r))
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
#
|
(tx_hash, o) = c.transfer(self.address, self.accounts[1], self.accounts[2], 500)
|
||||||
# balance_alice = self.contract.functions.balanceOf(self.w3.eth.accounts[1]).call()
|
self.rpc.do(o)
|
||||||
# self.assertEqual(balance_alice, 524)
|
o = receipt(tx_hash)
|
||||||
#
|
r = self.rpc.do(o)
|
||||||
# balance_bob = self.contract.functions.balanceOf(self.w3.eth.accounts[2]).call()
|
self.assertEqual(r['status'], 1)
|
||||||
# self.assertEqual(balance_bob, 500)
|
|
||||||
#
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
# tx_hash = self.contract.functions.transfer(self.w3.eth.accounts[2], 500).transact({'from': self.w3.eth.accounts[1]})
|
r = self.rpc.do(o)
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
balance = c.parse_balance_of(r)
|
||||||
# self.assertEqual(r.status, 1)
|
self.assertEqual(balance, 524)
|
||||||
# logg.debug('tx {}'.format(r))
|
|
||||||
#
|
o = c.balance_of(self.address, self.accounts[2], sender_address=self.accounts[0])
|
||||||
#
|
r = self.rpc.do(o)
|
||||||
# def test_transfer_from(self):
|
balance = c.parse_balance_of(r)
|
||||||
# tx_hash = self.contract.functions.mintTo(self.w3.eth.accounts[1], 1024).transact()
|
self.assertEqual(balance, 500)
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
|
||||||
# self.assertEqual(r.status, 1)
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
#
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# tx_hash = self.contract.functions.approve(self.w3.eth.accounts[2], 500).transact({'from': self.w3.eth.accounts[1]})
|
(tx_hash, o) = c.transfer(self.address, self.accounts[2], self.accounts[1], 500)
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
self.rpc.do(o)
|
||||||
# self.assertEqual(r.status, 1)
|
o = receipt(tx_hash)
|
||||||
# logg.debug('tx {}'.format(r))
|
r = self.rpc.do(o)
|
||||||
#
|
self.assertEqual(r['status'], 1)
|
||||||
# balance_alice = self.contract.functions.balanceOf(self.w3.eth.accounts[1]).call()
|
|
||||||
# self.assertEqual(balance_alice, 1024)
|
|
||||||
#
|
|
||||||
# tx_hash = self.contract.functions.transferFrom(self.w3.eth.accounts[1], self.w3.eth.accounts[3], 500).transact({'from': self.w3.eth.accounts[2]})
|
def test_transfer_from(self):
|
||||||
# r = self.w3.eth.getTransactionReceipt(tx_hash)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||||
# self.assertEqual(r.status, 1)
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# logg.debug('tx {}'.format(r))
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1024)
|
||||||
#
|
self.rpc.do(o)
|
||||||
# balance_alice = self.contract.functions.balanceOf(self.w3.eth.accounts[1]).call()
|
|
||||||
# self.assertEqual(balance_alice, 524)
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
||||||
#
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
# balance_alice = self.contract.functions.balanceOf(self.w3.eth.accounts[3]).call()
|
(tx_hash, o) = c.approve(self.address, self.accounts[1], self.accounts[2], 500)
|
||||||
# self.assertEqual(balance_alice, 500)
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
balance = c.parse_balance_of(r)
|
||||||
|
self.assertEqual(balance, 1024)
|
||||||
|
|
||||||
|
nonce_oracle = RPCNonceOracle(self.accounts[2], self.rpc)
|
||||||
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
(tx_hash, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], 500)
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
|
||||||
|
o = c.balance_of(self.address, self.accounts[1], sender_address=self.accounts[0])
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
balance = c.parse_balance_of(r)
|
||||||
|
self.assertEqual(balance, 524)
|
||||||
|
|
||||||
|
o = c.balance_of(self.address, self.accounts[3], sender_address=self.accounts[0])
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
balance = c.parse_balance_of(r)
|
||||||
|
self.assertEqual(balance, 500)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user