2021-10-11 08:57:03 +02:00
|
|
|
# standard imports
|
2022-02-21 06:34:25 +01:00
|
|
|
import logging
|
2021-10-11 08:57:03 +02:00
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from cic import Proof
|
|
|
|
from cic.attachment import Attachment
|
|
|
|
|
|
|
|
# test imports
|
2022-02-21 06:34:25 +01:00
|
|
|
from tests.base_cic import TestCICBase, root_merged_hash, test_data_dir
|
2021-10-11 08:57:03 +02:00
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
2022-02-21 06:34:25 +01:00
|
|
|
|
2021-10-11 19:02:42 +02:00
|
|
|
class TestProof(TestCICBase):
|
2022-02-21 06:34:25 +01:00
|
|
|
def test_proof(self):
|
|
|
|
proof_path = os.path.join(test_data_dir, "proof")
|
|
|
|
attach = Attachment(proof_path, writer=self.outputs_writer)
|
|
|
|
attach.load()
|
|
|
|
c = Proof(path=proof_path, attachments=attach)
|
|
|
|
c.load()
|
|
|
|
self.assertEquals(
|
|
|
|
str(c),
|
|
|
|
"""description = foo bar baz
|
|
|
|
issuer = the man
|
|
|
|
namespace = ge
|
|
|
|
version = 0
|
|
|
|
proofs[0] = 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
|
|
|
|
proofs[1] = fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9
|
|
|
|
""",
|
|
|
|
)
|
2021-10-11 08:57:03 +02:00
|
|
|
|
|
|
|
def test_proof_serialize_merge(self):
|
2022-02-21 06:34:25 +01:00
|
|
|
proof_path = os.path.join(test_data_dir, "proof")
|
2021-10-11 08:57:03 +02:00
|
|
|
|
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()
|
2021-10-22 16:42:38 +02:00
|
|
|
v = c.process(token_address=self.token_address, token_symbol=self.token_symbol)
|
2021-10-11 19:02:42 +02:00
|
|
|
self.assertEqual(v, root_merged_hash)
|
2021-10-11 08:57:03 +02:00
|
|
|
|
|
|
|
|
2022-02-21 06:34:25 +01:00
|
|
|
if __name__ == "__main__":
|
2021-10-11 08:57:03 +02:00
|
|
|
unittest.main()
|