mirror of
git://holbrook.no/erc20-demurrage-token
synced 2024-11-16 14:16:46 +01:00
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
# standard imports
|
|
import os
|
|
import unittest
|
|
import json
|
|
import logging
|
|
|
|
# external imports
|
|
from chainlib.eth.constant import ZERO_ADDRESS
|
|
from chainlib.eth.nonce import RPCNonceOracle
|
|
from chainlib.eth.tx import receipt
|
|
from chainlib.eth.block import block_latest
|
|
from chainlib.eth.block import block_by_number
|
|
|
|
# local imports
|
|
from erc20_demurrage_token import DemurrageToken
|
|
|
|
# test imports
|
|
from erc20_demurrage_token.unittest import TestDemurrageDefault
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
logg = logging.getLogger()
|
|
|
|
testdir = os.path.dirname(__file__)
|
|
|
|
class TestAmounts(TestDemurrageDefault):
|
|
|
|
def test_mint(self):
|
|
o = block_latest()
|
|
r = self.rpc.do(o)
|
|
o = block_by_number(r)
|
|
r = self.rpc.do(o)
|
|
tb = r['timestamp']
|
|
self.backend.time_travel(self.start_time + 800)
|
|
o = block_latest()
|
|
r = self.rpc.do(o)
|
|
o = block_by_number(r)
|
|
r = self.rpc.do(o)
|
|
ta = r['timestamp']
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], 1000)
|
|
r = self.rpc.do(o)
|
|
o = receipt(tx_hash)
|
|
r = self.rpc.do(o)
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
|
|
def test_writer(self):
|
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[1], 1000)
|
|
r = self.rpc.do(o)
|
|
o = receipt(tx_hash)
|
|
r = self.rpc.do(o)
|
|
self.assertEqual(r['status'], 0)
|
|
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
(tx_hash, o) = c.add_writer(self.address, self.accounts[0], self.accounts[1])
|
|
r = self.rpc.do(o)
|
|
o = receipt(tx_hash)
|
|
r = self.rpc.do(o)
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[1], self.rpc)
|
|
c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[1], self.accounts[1], 1000)
|
|
r = self.rpc.do(o)
|
|
o = receipt(tx_hash)
|
|
r = self.rpc.do(o)
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|