test_eip165.py (1980B)
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 ( 12 TxFactory, 13 receipt, 14 ) 15 16 # local imports 17 from eth_interface import ERC165 18 from eth_interface.unittest import TestERC165 19 20 logging.basicConfig(level=logging.DEBUG) 21 logg = logging.getLogger() 22 23 script_dir = os.path.realpath(os.path.dirname(__file__)) 24 25 26 class TestSupports(EthTesterCase, TestERC165): 27 28 def setUp(self): 29 super(TestSupports, self).setUp() 30 self.conn = RPCConnection.connect(self.chain_spec, 'default') 31 nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) 32 33 f = open(os.path.join(script_dir, 'testdata', 'Supports.bin')) 34 code = f.read() 35 f.close() 36 37 txf = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) 38 tx = txf.template(self.accounts[0], None, use_nonce=True) 39 tx = txf.set_code(tx, code) 40 (tx_hash_hex, o) = txf.build(tx) 41 42 r = self.conn.do(o) 43 logg.debug('deployed with hash {}'.format(r)) 44 45 o = receipt(tx_hash_hex) 46 r = self.conn.do(o) 47 self.address = r['contract_address'] 48 49 50 # def test_supports(self): 51 # gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn) 52 # c = ERC165(self.chain_spec, gas_oracle=gas_oracle) 53 # o = c.supports_interface(self.address, '0xdeadbeef', sender_address=self.accounts[0]) 54 # r = self.conn.do(o) 55 # v = c.parse_supports_interface(r) 56 # self.assertEqual(v, 1) 57 # 58 # o = c.supports_interface(self.address, '0xbeeffeed', sender_address=self.accounts[0]) 59 # r = self.conn.do(o) 60 # v = c.parse_supports_interface(r) 61 # self.assertEqual(v, 0) 62 63 if __name__ == '__main__': 64 unittest.main()