cic-cli/tests/eth/base_eth.py
2021-10-10 21:30:18 +02:00

53 lines
1.5 KiB
Python

# standard imports import unittestimport logging
import random
import os
import logging
# external imports
from chainlib.chain import ChainSpec
from chainlib.eth.unittest.ethtester import EthTesterCase
from hexathon import (
add_0x,
strip_0x,
)
from funga.eth.keystore.dict import DictKeystore
# local imports
from cic.ext.eth import CICEth
from cic import Proof
from cic.attachment import Attachment
# test imports
from tests.base_cic import test_data_dir
logg = logging.getLogger(__name__)
class TestCICEthBase(EthTesterCase):
def setUp(self):
super(TestCICEthBase, self).setUp()
random.seed(42)
self.token_address = add_0x(random.randbytes(20).hex())
self.token_index_address = add_0x(random.randbytes(20).hex())
addresses = self.keystore.list()
self.resources = {
'token': {
'reference': self.token_address,
'key_address': addresses[0],
},
'token_index': {
'reference': self.token_index_address,
'key_address': addresses[1],
},
'address_declarator': {
'reference': self.token_index_address,
'key_address': addresses[2],
},
}
proof_dir = os.path.join(test_data_dir, 'proof')
attach = Attachment(path=proof_dir)
attach.load()
self.proofs = Proof(proof_dir, attachments=attach)
self.proofs.load()