# standard imports import unittest import logging import random # external imports from chainlib.chain import ChainSpec from hexathon import ( add_0x, strip_0x, ) # local imports from cic.ext.eth import CICEth logg = logging.getLogger(__name__) class TestCICEth(unittest.TestCase): def setUp(self): random.seed(42) self.chain_spec = ChainSpec.from_chain_str('evm:foo:42') self.token_address = add_0x(random.randbytes(20).hex()) self.token_index_address = add_0x(random.randbytes(20).hex()) self.resources = { 'token': { 'reference': self.token_address, 'key_address': None, }, 'token_index': { 'reference': self.token_index_address, 'key_address': None, }, } self.proofs = [] for i in range(3): self.proofs.append(random.randbytes(32).hex()) self.adapter = CICEth(self.chain_spec, self.resources, self.proofs) def test_offline_token_index(self): self.adapter.token_address = self.token_address v = self.adapter.process_token_index() self.assertEqual(self.adapter.outputs['token_index'][:8], '4420e486') if __name__ == '__main__': unittest.main()