cic-cli/tests/test_proof.py

48 lines
1.4 KiB
Python

# standard imports
import os
import unittest
import logging
# local imports
from cic.contract.components.proof import Proof
from cic.contract.components.attachment import Attachment
# test imports
from tests.base_cic import test_data_dir, TestCICBase, root_merged_hash
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
class TestProof(TestCICBase):
def test_proof_load(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
""",
)
def test_proof_serialize_merge(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, writer=self.outputs_writer)
c.load()
v = c.process(token_address=self.token_address, token_symbol=self.token_symbol)
self.assertEqual(v, root_merged_hash)
if __name__ == "__main__":
unittest.main()