erc20-demurrage-token

ERC20 token with redistributed continual demurrage
Info | Log | Files | Refs | README

test_cap.py (2041B)


      1 import os
      2 import unittest
      3 import json
      4 import logging
      5 
      6 # external imports
      7 from chainlib.eth.constant import ZERO_ADDRESS
      8 from chainlib.eth.nonce import RPCNonceOracle
      9 from chainlib.eth.tx import receipt
     10 from chainlib.eth.block import block_latest
     11 from chainlib.eth.address import to_checksum_address
     12 from hexathon import (
     13         strip_0x,
     14         add_0x,
     15         )
     16 
     17 # local imports
     18 from erc20_demurrage_token import DemurrageToken
     19 
     20 # test imports
     21 from erc20_demurrage_token.unittest import TestDemurrageDefault
     22 
     23 logging.basicConfig(level=logging.DEBUG)
     24 logg = logging.getLogger()
     25 
     26 testdir = os.path.dirname(__file__)
     27 
     28 
     29 class TestCap(TestDemurrageDefault):
     30 
     31     def test_cap(self):
     32         nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
     33         c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     34 
     35         o = c.total_supply(self.address, sender_address=self.accounts[0])
     36         r = self.rpc.do(o)
     37         logg.debug('r {}'.format(r))
     38 
     39         (tx_hash, o) = c.set_max_supply(self.address, self.accounts[0], self.default_supply_cap)
     40         r = self.rpc.do(o)
     41         o = receipt(tx_hash)
     42         r = self.rpc.do(o)
     43         self.assertEqual(r['status'], 1)
     44 
     45         o = c.max_supply(self.address, sender_address=self.accounts[0])
     46         r = self.rpc.do(o)
     47         cap = c.parse_supply_cap(r)
     48         self.assertEqual(cap, self.default_supply_cap)
     49 
     50         nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
     51         c = DemurrageToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     52         (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[1], self.default_supply_cap)
     53         r = self.rpc.do(o)
     54         o = receipt(tx_hash)
     55         r = self.rpc.do(o)
     56         self.assertEqual(r['status'], 1)
     57 
     58         (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[2], 1)
     59         r = self.rpc.do(o)
     60         o = receipt(tx_hash)
     61         r = self.rpc.do(o)
     62         self.assertEqual(r['status'], 0)
     63 
     64 
     65 if __name__ == '__main__':
     66     unittest.main()