2021-10-10 13:20:00 +02:00
|
|
|
# standard imports
|
|
|
|
import unittest
|
2021-10-11 12:23:08 +02:00
|
|
|
import logging
|
2021-10-11 17:39:01 +02:00
|
|
|
import os
|
2021-10-10 13:20:00 +02:00
|
|
|
|
|
|
|
# local imports
|
|
|
|
from cic.ext.eth import CICEth
|
2021-10-11 15:28:09 +02:00
|
|
|
from cic.processor import Processor
|
2021-10-10 13:20:00 +02:00
|
|
|
|
|
|
|
# tests imports
|
|
|
|
from tests.eth.base_eth import TestCICEthBase
|
|
|
|
|
2021-10-11 12:23:08 +02:00
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
|
2021-10-10 13:20:00 +02:00
|
|
|
class TestCICEthOffline(TestCICEthBase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestCICEthOffline, self).setUp()
|
2021-10-11 15:28:09 +02:00
|
|
|
self.adapter = CICEth(self.chain_spec, self.resources, self.proofs)
|
2021-11-29 13:18:28 +01:00
|
|
|
self.first_proof = self.proofs.root()[0]
|
2021-10-10 13:20:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_offline_token_index(self):
|
|
|
|
self.adapter.token_address = self.token_address
|
2021-10-15 12:48:14 +02:00
|
|
|
self.adapter.process_token_index(writer=self.outputs_writer)
|
2021-10-11 15:28:09 +02:00
|
|
|
self.assertEqual(self.adapter.outputs[0][0], 'token_index')
|
|
|
|
self.assertEqual(self.adapter.outputs[0][1][:8], '4420e486')
|
2021-10-10 13:20:00 +02:00
|
|
|
|
|
|
|
|
2021-10-10 14:00:47 +02:00
|
|
|
def test_offline_address_declarator(self):
|
2021-10-10 14:06:40 +02:00
|
|
|
self.adapter.token_address = self.token_address
|
2021-10-11 15:28:09 +02:00
|
|
|
self.adapter.process_address_declarator()
|
2021-10-11 17:39:01 +02:00
|
|
|
self.assertEqual(self.adapter.outputs[0][0], 'address_declarator_' + self.first_proof)
|
2021-10-11 15:28:09 +02:00
|
|
|
self.assertEqual(self.adapter.outputs[0][1][:8], 'ae47ece0')
|
2021-10-10 14:06:40 +02:00
|
|
|
|
2021-10-10 14:00:47 +02:00
|
|
|
|
2021-10-11 17:39:01 +02:00
|
|
|
def test_offline_writer(self):
|
|
|
|
self.adapter.outputs_writer = self.outputs_writer
|
|
|
|
self.adapter.token_address = self.token_address
|
|
|
|
self.adapter.process_address_declarator()
|
2021-11-29 13:18:28 +01:00
|
|
|
logg.debug('proofs {}'.format(self.proofs))
|
2021-10-15 12:48:14 +02:00
|
|
|
logg.debug('outputs {}'.format(self.adapter.outputs))
|
2021-10-11 17:39:01 +02:00
|
|
|
self.assertEqual(self.adapter.outputs[0][0], 'address_declarator_' + self.first_proof)
|
|
|
|
self.assertEqual(self.adapter.outputs[0][1][:8], 'ae47ece0')
|
|
|
|
|
|
|
|
for i, v in enumerate(self.adapter.outputs):
|
|
|
|
fp = os.path.join(self.outputs_dir, v[0])
|
|
|
|
f = open(fp, 'rb')
|
|
|
|
r = f.read()
|
|
|
|
f.close()
|
|
|
|
self.assertEqual(r.decode('utf-8'), v[1])
|
|
|
|
|
2021-10-10 15:37:26 +02:00
|
|
|
|
2021-10-10 13:20:00 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|