mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Output.from_dict accepts string
This commit is contained in:
parent
56b81f9d8d
commit
f23bfa52d1
@ -264,7 +264,7 @@ class Output(object):
|
||||
output = {
|
||||
'public_keys': self.public_keys,
|
||||
'condition': condition,
|
||||
'amount': self.amount
|
||||
'amount': str(self.amount),
|
||||
}
|
||||
return output
|
||||
|
||||
@ -381,7 +381,11 @@ class Output(object):
|
||||
except KeyError:
|
||||
# NOTE: Hashlock condition case
|
||||
fulfillment = data['condition']['uri']
|
||||
return cls(fulfillment, data['public_keys'], data['amount'])
|
||||
try:
|
||||
amount = int(data['amount'])
|
||||
except ValueError:
|
||||
raise AmountError('Invalid amount: %s' % amount)
|
||||
return cls(fulfillment, data['public_keys'], amount)
|
||||
|
||||
|
||||
class Transaction(object):
|
||||
|
@ -83,7 +83,7 @@ def test_output_serialization(user_Ed25519, user_pub):
|
||||
'details': user_Ed25519.to_dict(),
|
||||
},
|
||||
'public_keys': [user_pub],
|
||||
'amount': 1,
|
||||
'amount': '1',
|
||||
}
|
||||
|
||||
cond = Output(user_Ed25519, [user_pub], 1)
|
||||
@ -101,7 +101,7 @@ def test_output_deserialization(user_Ed25519, user_pub):
|
||||
'details': user_Ed25519.to_dict()
|
||||
},
|
||||
'public_keys': [user_pub],
|
||||
'amount': 1,
|
||||
'amount': '1',
|
||||
}
|
||||
cond = Output.from_dict(cond)
|
||||
|
||||
@ -120,7 +120,7 @@ def test_output_hashlock_serialization():
|
||||
'uri': hashlock,
|
||||
},
|
||||
'public_keys': None,
|
||||
'amount': 1,
|
||||
'amount': '1',
|
||||
}
|
||||
cond = Output(hashlock, amount=1)
|
||||
|
||||
@ -140,7 +140,7 @@ def test_output_hashlock_deserialization():
|
||||
'uri': hashlock
|
||||
},
|
||||
'public_keys': None,
|
||||
'amount': 1,
|
||||
'amount': '1',
|
||||
}
|
||||
cond = Output.from_dict(cond)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user