mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Increase test coverage
This commit is contained in:
parent
e41ccae6bd
commit
331150b9c2
@ -83,7 +83,7 @@ class TransactionLink(object):
|
|||||||
self.cid = cid
|
self.cid = cid
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return not (self.txid is None and self.cid is None)
|
return self.txid is not None and self.cid is not None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self.to_dict() == self.to_dict()
|
return self.to_dict() == self.to_dict()
|
||||||
@ -346,14 +346,14 @@ class Transaction(object):
|
|||||||
ffill_tx = Fulfillment(ffill, owners_before)
|
ffill_tx = Fulfillment(ffill, owners_before)
|
||||||
return cls(cls.CREATE, [ffill_tx], [cond_tx], data)
|
return cls(cls.CREATE, [ffill_tx], [cond_tx], data)
|
||||||
|
|
||||||
elif len(owners_before) == 1 and len(owners_after) == 0 and time_expire is not None:
|
elif len(owners_before) > 0 and len(owners_after) == 0 and time_expire is not None:
|
||||||
raise NotImplementedError('Timeout conditions will be implemented later')
|
raise NotImplementedError('Timeout conditions will be implemented later')
|
||||||
|
|
||||||
elif len(owners_before) == 1 and len(owners_after) == 0 and secret is None:
|
elif len(owners_before) > 0 and len(owners_after) == 0 and secret is None:
|
||||||
raise ValueError('Define a secret to create a hashlock condition')
|
raise ValueError('Define a secret to create a hashlock condition')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("This is not the cases you're looking for ;)")
|
raise ValueError("These are not the cases you're looking for ;)")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def transfer(cls, inputs, owners_after, payload=None):
|
def transfer(cls, inputs, owners_after, payload=None):
|
||||||
@ -364,8 +364,6 @@ class Transaction(object):
|
|||||||
if not isinstance(owners_after, list):
|
if not isinstance(owners_after, list):
|
||||||
raise TypeError('`owners_after` must be a list instance')
|
raise TypeError('`owners_after` must be a list instance')
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# NOTE: Different cases for threshold conditions:
|
# NOTE: Different cases for threshold conditions:
|
||||||
#
|
#
|
||||||
# Combining multiple `inputs` with an arbitrary number of
|
# Combining multiple `inputs` with an arbitrary number of
|
||||||
@ -384,18 +382,15 @@ class Transaction(object):
|
|||||||
# `a`'s signature would have a 50% weight on `inp1`
|
# `a`'s signature would have a 50% weight on `inp1`
|
||||||
# compared to `b` and `c` that share 25% of the leftover
|
# compared to `b` and `c` that share 25% of the leftover
|
||||||
# weight respectively. `inp2` is owned completely by `d`.
|
# weight respectively. `inp2` is owned completely by `d`.
|
||||||
#
|
if len(inputs) == len(owners_after):
|
||||||
#
|
if len(owners_after) == 1:
|
||||||
if len(inputs) == len(owners_after) and len(owners_after) == 1:
|
|
||||||
conditions = [Condition.generate(owners_after)]
|
conditions = [Condition.generate(owners_after)]
|
||||||
elif len(inputs) == len(owners_after) and len(owners_after) > 1:
|
elif len(owners_after) > 1:
|
||||||
conditions = [Condition.generate(owners) for owners
|
conditions = [Condition.generate(owners) for owners
|
||||||
in owners_after]
|
in owners_after]
|
||||||
elif len(inputs) != len(owners_after):
|
else:
|
||||||
raise ValueError("`inputs` and `owners_after`'s count must be the "
|
raise ValueError("`inputs` and `owners_after`'s count must be the "
|
||||||
"same")
|
"same")
|
||||||
else:
|
|
||||||
raise ValueError("This is not the cases you're looking for ;)")
|
|
||||||
|
|
||||||
data = Data(payload)
|
data = Data(payload)
|
||||||
inputs = deepcopy(inputs)
|
inputs = deepcopy(inputs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user