cic-cli/tests/eth/base_eth.py

53 lines
1.5 KiB
Python
Raw Normal View History

2021-10-10 21:30:18 +02:00
# standard imports import unittestimport logging
2021-10-10 12:50:18 +02:00
import random
2021-10-10 21:30:18 +02:00
import os
import logging
2021-10-10 12:50:18 +02:00
# external imports
from chainlib.chain import ChainSpec
2021-10-10 13:20:00 +02:00
from chainlib.eth.unittest.ethtester import EthTesterCase
2021-10-10 12:50:18 +02:00
from hexathon import (
add_0x,
strip_0x,
)
2021-10-10 13:20:00 +02:00
from funga.eth.keystore.dict import DictKeystore
2021-10-10 12:50:18 +02:00
# local imports
from cic.ext.eth import CICEth
2021-10-10 21:30:18 +02:00
from cic import Proof
from cic.attachment import Attachment
# test imports
from tests.base_cic import test_data_dir
2021-10-10 12:50:18 +02:00
logg = logging.getLogger(__name__)
2021-10-10 13:20:00 +02:00
class TestCICEthBase(EthTesterCase):
2021-10-10 12:50:18 +02:00
def setUp(self):
2021-10-10 13:20:00 +02:00
super(TestCICEthBase, self).setUp()
2021-10-10 12:50:18 +02:00
random.seed(42)
self.token_address = add_0x(random.randbytes(20).hex())
self.token_index_address = add_0x(random.randbytes(20).hex())
2021-10-10 13:20:00 +02:00
addresses = self.keystore.list()
2021-10-10 12:50:18 +02:00
self.resources = {
'token': {
'reference': self.token_address,
2021-10-10 13:20:00 +02:00
'key_address': addresses[0],
2021-10-10 12:50:18 +02:00
},
'token_index': {
'reference': self.token_index_address,
2021-10-10 13:20:00 +02:00
'key_address': addresses[1],
2021-10-10 12:50:18 +02:00
},
2021-10-10 14:06:40 +02:00
'address_declarator': {
'reference': self.token_index_address,
'key_address': addresses[2],
},
2021-10-10 12:50:18 +02:00
}
2021-10-10 21:30:18 +02:00
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()