eth-erc721

ERC-721 'NFT' token interface with example developer badge token contract
Info | Log | Files | Refs | LICENSE

base.py (1660B)


      1 # standard imports
      2 import os
      3 import unittest
      4 import json
      5 import logging
      6 
      7 # external imports
      8 from chainlib.eth.unittest.ethtester import EthTesterCase
      9 from chainlib.connection import RPCConnection
     10 from chainlib.eth.nonce import RPCNonceOracle
     11 from chainlib.eth.block import block_latest
     12 from chainlib.eth.address import to_checksum_address
     13 from chainlib.eth.tx import (
     14         receipt,
     15         transaction,
     16         TxFormat,
     17         )
     18 from chainlib.eth.contract import (
     19         abi_decode_single,
     20         ABIContractType,
     21         )
     22 from chainlib.error import JSONRPCException
     23 from chainlib.eth.constant import ZERO_ADDRESS
     24 
     25 
     26 # local imports
     27 from eth_badgetoken import BadgeToken
     28 
     29 logging.basicConfig(level=logging.DEBUG)
     30 logg = logging.getLogger(__name__)
     31 
     32 testdir = os.path.dirname(__file__)
     33 
     34 
     35 class TestBadgeToken(EthTesterCase):
     36 
     37     owner = None
     38     name = 'DevBadge'
     39     symbol = 'DEV'
     40     #decimals = 6
     41     initial_supply = 0
     42 
     43     def setUp(self):
     44         super(TestBadgeToken, self).setUp()
     45         nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
     46         c = BadgeToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     47         #(tx_hash, o) = c.constructor(self.accounts[0], b'\x00' * 20, 'DevBadge', 'DEV')
     48         (tx_hash, o) = c.constructor(self.accounts[0], 'DevBadge', 'DEV', self.accounts[1])
     49         self.conn = RPCConnection.connect(self.chain_spec, 'default')
     50         r = self.conn.do(o)
     51         logg.debug('deployed with hash {}'.format(r))
     52         
     53         o = receipt(r)
     54         r = self.conn.do(o)
     55         self.address = to_checksum_address(r['contract_address'])
     56 
     57         TestBadgeToken.owner = self.accounts[0]