eth-address-index

signed metadata declarations for ethereum addresses
Info | Log | Files | Refs

addressdeclarator.py (1625B)


      1 # standard imports
      2 import unittest
      3 import logging
      4 import os
      5 
      6 # external imports
      7 from hexathon import add_0x
      8 from chainlib.eth.unittest.ethtester import EthTesterCase
      9 from chainlib.eth.nonce import RPCNonceOracle
     10 from chainlib.eth.tx import receipt
     11 from giftable_erc20_token import GiftableToken
     12 
     13 # local imports
     14 from eth_address_declarator.declarator import AddressDeclarator
     15 #from eth_address_declarator.kv import AddressDeclaratorKV
     16 
     17 logging.basicConfig(level=logging.DEBUG)
     18 logg = logging.getLogger()
     19 
     20 
     21 class TestAddressDeclaratorBase(EthTesterCase):
     22 
     23     def setUp(self):
     24         super(TestAddressDeclaratorBase, self).setUp()
     25         self.description = add_0x(os.urandom(32).hex())
     26         nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
     27         c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     28         (tx_hash_hex, o) = c.constructor(self.accounts[0], self.description)
     29         self.rpc.do(o)
     30 
     31         o = receipt(tx_hash_hex)
     32         r = self.rpc.do(o)
     33         self.assertEqual(r['status'], 1)
     34 
     35         self.address = r['contract_address']
     36         logg.debug('address declarator published with address {}'.format(self.address))
     37 
     38         c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     39         (tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
     40         self.rpc.do(o)
     41 
     42         o = receipt(tx_hash_hex)
     43         r = self.rpc.do(o)
     44         self.assertEqual(r['status'], 1)
     45 
     46         self.foo_token_address = r['contract_address']
     47         logg.debug('foo token published with address {}'.format(self.foo_token_address))