Add proof processing

This commit is contained in:
nolash
2021-10-11 19:02:42 +02:00
parent 8451285d0d
commit 09fa8f2a4c
6 changed files with 43 additions and 12 deletions

View File

@@ -25,7 +25,6 @@ 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()),

View File

@@ -8,32 +8,40 @@ from cic import Proof
from cic.attachment import Attachment
# test imports
from tests.base_cic import test_data_dir
from tests.base_cic import (
test_data_dir,
TestCICBase,
)
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
proof_hash = '0f6fc017f29caf512c0feaaf83bc10614b488311cace2973dc248dc24b01e04f'
foo_hash = '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
bar_hash = 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'
root_merged_hash = '1b38b0e9a2cc0895c72e5f460a613bb0f3d88c4a87c1ee2b39a41c64f1dbcd1e'
root_unmerged_hash = '86d0091b98635a45da472388a1204104d7d10ea1199c1bd9c1d235de73a2c285'
class TestProof(unittest.TestCase):
class TestProof(TestCICBase):
def test_proof_serialize(self):
proof_path = os.path.join(test_data_dir, 'proof')
c = Proof(path=proof_path)
v = c.get()
logg.debug('v {}'.format(v))
c = Proof(path=proof_path, writer=self.outputs_writer)
c.load()
v = c.process()
self.assertEqual(v, root_unmerged_hash)
def test_proof_serialize_merge(self):
proof_path = os.path.join(test_data_dir, 'proof')
attach = Attachment(proof_path)
attach = Attachment(proof_path, writer=self.outputs_writer)
attach.load()
c = Proof(path=proof_path, attachments=attach)
v = c.get()
c = Proof(path=proof_path, attachments=attach, writer=self.outputs_writer)
c.load()
v = c.process()
self.assertEqual(v, root_merged_hash)
if __name__ == '__main__':