cic-cli/tests/test_proof.py

49 lines
1.4 KiB
Python
Raw Normal View History

2021-10-11 08:57:03 +02:00
# standard imports
import os
import unittest
import logging
# local imports
from cic import Proof
from cic.attachment import Attachment
# test imports
2021-10-11 19:02:42 +02:00
from tests.base_cic import (
test_data_dir,
TestCICBase,
)
2021-10-11 08:57:03 +02:00
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
2021-10-11 19:02:42 +02:00
proof_hash = '0f6fc017f29caf512c0feaaf83bc10614b488311cace2973dc248dc24b01e04f'
2021-10-11 08:57:03 +02:00
foo_hash = '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
bar_hash = 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'
2021-10-11 19:02:42 +02:00
root_merged_hash = '1b38b0e9a2cc0895c72e5f460a613bb0f3d88c4a87c1ee2b39a41c64f1dbcd1e'
root_unmerged_hash = '86d0091b98635a45da472388a1204104d7d10ea1199c1bd9c1d235de73a2c285'
2021-10-11 08:57:03 +02:00
2021-10-11 19:02:42 +02:00
class TestProof(TestCICBase):
2021-10-11 08:57:03 +02:00
def test_proof_serialize(self):
proof_path = os.path.join(test_data_dir, 'proof')
2021-10-11 19:02:42 +02:00
c = Proof(path=proof_path, writer=self.outputs_writer)
c.load()
v = c.process()
self.assertEqual(v, root_unmerged_hash)
2021-10-11 08:57:03 +02:00
def test_proof_serialize_merge(self):
proof_path = os.path.join(test_data_dir, 'proof')
2021-10-11 19:02:42 +02:00
attach = Attachment(proof_path, writer=self.outputs_writer)
2021-10-11 08:57:03 +02:00
attach.load()
2021-10-11 19:02:42 +02:00
c = Proof(path=proof_path, attachments=attach, writer=self.outputs_writer)
c.load()
v = c.process()
self.assertEqual(v, root_merged_hash)
2021-10-11 08:57:03 +02:00
if __name__ == '__main__':
unittest.main()