Add cic base test fixture

This commit is contained in:
nolash 2021-10-11 12:27:51 +02:00
parent 6822e09066
commit dd9640b383
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 81 additions and 0 deletions

View File

@ -1,5 +1,61 @@
# standard imports # standard imports
import os import os
import tempfile
import logging
import unittest
import random
# external imports
from hexathon import add_0x
# local imports
from cic.output import KVWriter
from cic.processor import Processor
from cic.attachment import Attachment
from cic import Proof
logg = logging.getLogger(__name__)
test_base_dir = os.path.dirname(os.path.realpath(__file__)) test_base_dir = os.path.dirname(os.path.realpath(__file__))
test_data_dir = os.path.join(test_base_dir, 'testdata') test_data_dir = os.path.join(test_base_dir, 'testdata')
class TestCICBase(unittest.TestCase):
def setUp(self):
super(TestCICBase, self).setUp()
random.seed(42)
self.initial_description = add_0x(random.randbytes(32).hex())
addresses = [
add_0x(random.randbytes(20).hex()),
add_0x(random.randbytes(20).hex()),
add_0x(random.randbytes(20).hex()),
]
self.token_address = add_0x(random.randbytes(32).hex())
self.token_index_address = add_0x(random.randbytes(32).hex())
self.address_declarator_address = add_0x(random.randbytes(32).hex())
d = tempfile.mkdtemp()
self.outputs_writer = KVWriter(d)
self.core_processor = Processor(self.token_address, outputs_writer=self.outputs_writer)
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.address_declarator_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()

25
tests/test_meta.py Normal file
View File

@ -0,0 +1,25 @@
# standard imports
import unittest
import logging
# external imports
from hexathon import strip_0x
# local imports
from cic.output import KVWriter
# test imports
from tests.base_cic import TestCICBase
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class TestCICMeta(TestCICBase):
def test_meta(self):
pass
if __name__ == '__main__':
unittest.main()