Catch CC Error for Fulfillment

This commit is contained in:
tim 2016-09-16 11:12:55 +02:00 committed by Sylvain Bellemare
parent 2ae5d49783
commit ab3473b0a0

View File

@ -3,26 +3,15 @@ from functools import reduce
from operator import and_ from operator import and_
from uuid import uuid4 from uuid import uuid4
from cryptoconditions import ( from cryptoconditions import (Fulfillment as CCFulfillment,
Fulfillment as CCFulfillment, ThresholdSha256Fulfillment, Ed25519Fulfillment,
ThresholdSha256Fulfillment, PreimageSha256Fulfillment)
Ed25519Fulfillment,
PreimageSha256Fulfillment,
)
from cryptoconditions.exceptions import ParsingError from cryptoconditions.exceptions import ParsingError
from bigchaindb_common.crypto import ( from bigchaindb_common.crypto import SigningKey, hash_data
SigningKey, from bigchaindb_common.exceptions import (KeypairMismatchException,
hash_data, InvalidHash, InvalidSignature)
) from bigchaindb_common.util import serialize, gen_timestamp
from bigchaindb_common.exceptions import (
KeypairMismatchException,
InvalidHash,
)
from bigchaindb_common.util import (
serialize,
gen_timestamp,
)
class Fulfillment(object): class Fulfillment(object):
@ -77,6 +66,9 @@ class Fulfillment(object):
""" """
try: try:
fulfillment = CCFulfillment.from_uri(ffill['fulfillment']) fulfillment = CCFulfillment.from_uri(ffill['fulfillment'])
except ValueError:
# TODO FOR CC: Throw an `InvalidSignature` error in this case.
raise InvalidSignature("Fulfillment URI could'nt been parsed")
except TypeError: except TypeError:
# NOTE: See comment about this special case in # NOTE: See comment about this special case in
# `Fulfillment.to_dict` # `Fulfillment.to_dict`