base.py (1348B)
1 # standard imports 2 import unittest 3 import os 4 import logging 5 6 # external imports 7 from chainlib.eth.unittest.ethtester import EthTesterCase 8 from chainlib.eth.nonce import RPCNonceOracle 9 from chainlib.eth.gas import OverrideGasOracle 10 from chainlib.connection import RPCConnection 11 from chainlib.eth.tx import TxFactory 12 from chainlib.eth.tx import receipt 13 from hexathon import strip_0x 14 15 # local imports 16 from eth_owned import ERC173 17 18 logging.basicConfig(level=logging.DEBUG) 19 logg = logging.getLogger() 20 21 script_dir = os.path.realpath(os.path.dirname(__file__)) 22 23 24 class TestOwned(EthTesterCase): 25 26 def setUp(self): 27 super(TestOwned, self).setUp() 28 self.conn = RPCConnection.connect(self.chain_spec, 'default') 29 nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) 30 31 f = open(os.path.join(script_dir, '..', 'data', 'OwnedSimple.bin')) 32 code = f.read() 33 f.close() 34 35 txf = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) 36 tx = txf.template(self.accounts[0], None, use_nonce=True) 37 tx = txf.set_code(tx, code) 38 (tx_hash_hex, o) = txf.build(tx) 39 40 r = self.conn.do(o) 41 logg.debug('Owned test conrtact published with hash {}'.format(r)) 42 43 o = receipt(tx_hash_hex) 44 r = self.conn.do(o) 45 self.address = r['contract_address']