eth-accounts-index

Accounts index evm contract tooling with permissioned writes
Info | Log | Files | Refs

base.py (1204B)


      1 # standard imports
      2 import logging
      3 
      4 # external imports
      5 from chainlib.eth.unittest.ethtester import EthTesterCase
      6 from chainlib.connection import RPCConnection
      7 from chainlib.eth.nonce import RPCNonceOracle
      8 from chainlib.eth.address import to_checksum_address
      9 from chainlib.eth.tx import receipt
     10 
     11 # local imports
     12 from eth_accounts_index.registry import AccountRegistry
     13 
     14 logg = logging.getLogger(__name__)
     15 
     16 
     17 class TestAccountsIndex(EthTesterCase):
     18 
     19     def setUp(self):
     20         super(TestAccountsIndex, self).setUp()
     21         self.conn = RPCConnection.connect(self.chain_spec, 'default')
     22         nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
     23 
     24         c = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     25         (tx_hash, o) = c.constructor(self.accounts[0])
     26         r = self.conn.do(o)
     27         logg.debug(f'published with hash {r}')
     28 
     29         o = receipt(r)
     30         r = self.conn.do(o)
     31         self.address = to_checksum_address(r['contract_address'])
     32 
     33         (tx_hash, o) = c.add_writer(self.address, self.accounts[0], self.accounts[0])
     34         r = self.conn.do(o)
     35 
     36         o = receipt(r)
     37         r = self.conn.do(o)
     38         self.assertEqual(r['status'], 1)